Fibonacci Series In Java Programs
class Fibonacci{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number till which you
want a Fibonacci Series = ");
int n = sc.nextInt();
int a = 0;
int b = 1;
int count = 2;
while (count<=n){
System.out.println(b + " ");
int c = a + b;
a = b;
b = c;
count++;
}
System.out.println(b);
}
}