I'm programming a recursive definition of the sine function in Java using it's Taylor approximation, but getting a noSuchMethodException
upon running the code. Here's what I have so far:
public static void Main(String[] args){
System.out.println("The approximate sine of pi over 2 with an accuracy index of ten is:");
System.out.println(Mathematics.recursiveSine(Math.PI/2,10));
}
public static double recursiveSine(double value, int index){
if(index==1) {
return value;
}
return ((double) ((-1)^(2*index + 1)) * Math.pow(value,2*index + 1)/factorial(2*index + 1)) + recursiveSine(value, index-1);
}
public static int factorial(int value){
return value==1 ? value : value*factorial(value-1);
}
Your main method needs to be lowercase.
You have
public static void Main(String[] args){
Should be
public static void main(String[] args){
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments