PROGRAM FOR CALCULATING "FABONACCI NUMBER" IN JAVA
import jdk.swing.interop.SwingInterOpUtils;
import java.util.Scanner;
public class fabonacciNumber {
public static void main(String [] args){
Scanner Scan = new Scanner((System.in));
int a = 0;
int b =1 ;
System.out.println("ENTER THE NUMBER UPTO THAT YOU WNAT TO CONTINUE THIS SERIES");
int n = Scan.nextInt();
System.out.print( a +" ");
System.out.print(b + " ");
int sum;
for (int i =0 ; i<n-2 ;i++){
sum = a+b;
System.out.print(sum+" ");
a=b;
b=sum;
}
}
}
Comments
Post a Comment