2
Ich programmiere eine rekursive Definition der Sinus-Funktion in Java mit seiner Taylor-Approximation, aber eine noSuchMethodException
beim Ausführen des Codes. Hier ist, was ich bisher habe:Getting a noSuchMethodException
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);
}
Sie haben einen Tippfehler sein, die wichtigste Methode genannt 'main', nicht' Main'. – Berger
'main' muss einen Kleinbuchstaben' m' haben. – ajb
'Mathematik.ist nicht notwendig, wenn es in der gleichen Klasse aufgerufen wird – Andrew