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

Popular posts from this blog

PROGRAM OF CALCULATING INTERSECTION OF TWO ARRAYS

JAVA PROGRAM TO CREATE A DATABASE (SAMPLE PICTURE IS GIVEN)

Craze for Fashion