Created
September 14, 2019 07:26
-
-
Save h26k2/14e0ab37c7969e7c7fca559ac906c4bd to your computer and use it in GitHub Desktop.
fibonacci-series java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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