Skip to content

Commit 2e9aa20

Browse files
Merge pull request #201 from shreeamahadik/patch-1
java code
2 parents 951498d + 81eecbf commit 2e9aa20

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

fibonacci

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class FibonacciExample1{
2+
public static void main(String args[])
3+
{
4+
int n1=0,n2=1,n3,i,count=10;
5+
System.out.print(n1+" "+n2);//printing 0 and 1
6+
7+
for(i=2;i<count;++i)//loop starts from 2 because 0 and 1 are already printed
8+
{
9+
n3=n1+n2;
10+
System.out.print(" "+n3);
11+
n1=n2;
12+
n2=n3;
13+
}
14+
15+
}}

0 commit comments

Comments
 (0)