what are fibonacci numbers in code code example
Example: give a code for fibonacci numbers
import java.util.Scanner;
public class fibonaci {
public static void main(String[] args) {
System.out.println ("Enter number of terms in the Series");
Scanner sc = new Scanner (System.in);
int n = sc.nextInt ();
for (int i = 0; i < n; i++) {
System.out.print (fibo (i) + " ");
}
}
public static int fibo(int i) {
if (i == 0) {
return 0;
} else if (i == 1) {
return 1;
} else {
return fibo (i - 1) + fibo (i - 2);
}
}
}