Skip to content

Commit

Permalink
Create Fibonacci.java
Browse files Browse the repository at this point in the history
  • Loading branch information
3aryansingh committed Oct 6, 2020
1 parent 1f752dd commit 3aa34d3
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Java_Programs_for_beginners/Fibonacci.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class FibonacciExample{
public static void main(String args[])
{
int n1=0,n2=1,n3,i,count=10;
System.out.print(n1+" "+n2);//printing 0 and 1

for(i=2;i<count;++i)//loop starts from 2 because 0 and 1 are already printed
{
n3=n1+n2;
System.out.print(" "+n3);
n1=n2;
n2=n3;
}

}}

0 comments on commit 3aa34d3

Please sign in to comment.