Skip to content

Instantly share code, notes, and snippets.

@h26k2
Created September 14, 2019 07:26
Show Gist options
  • Save h26k2/14e0ab37c7969e7c7fca559ac906c4bd to your computer and use it in GitHub Desktop.
Save h26k2/14e0ab37c7969e7c7fca559ac906c4bd to your computer and use it in GitHub Desktop.
fibonacci-series java
Scanner input = new Scanner(System.in);
int num1 , num2 , nextNum , count;
num1 = 0;
num2 = 1;
System.out.println("How many number of fibonacii series you want ?");
count = input.nextInt();
System.out.println("================== FIBONACCI SERIES IS =============");
System.out.println(num1);
System.out.println(num2);
for(int i=1 ; i <= (count-2) ; i++){
nextNum = num1 + num2;
System.out.println(nextNum);
num1 = num2;
num2 = nextNum;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment