Fibonacci Series :-
Code :-
import java.util.Scanner;
public class Fibonacci {
public static void main(String arg[]){
Scanner in = new Scanner(System.in);
int n = in.nextInt();
for (int i = 0; i <= n; i++) {
System.out.print(fibonacci(i) + " ");
}
in.close();
}
public static int fibonacci(int n) {
if (n == 0) {
return 0;
} else if (n == 1) {
return 1;
} else {
return fibonacci(n - 1) + fibonacci(n - 2);
}
}
}
Output:-
100 1 1 2 3 5 8 13 21 34 55