Created
November 19, 2015 12:25
-
-
Save eMahtab/bb3eaff5f710cd970520 to your computer and use it in GitHub Desktop.
Java program to print fibonacci numbers. In Fibonacci series each number is sum of previous two numbers.
This file contains hidden or 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
public class Fibonacci{ | |
public static void main(String args[]){ | |
int n1=0; | |
int n2=1; | |
int next=0; | |
System.out.print(n1+" "+n2+" "); | |
int loop=1; | |
while(loop<11){ | |
next=n1+n2; | |
n1=n2; | |
n2=next; | |
System.out.print(next+" "); | |
loop++; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment