Skip to content

Commit be1a4f6

Browse files
Merge pull request #165 from MrB141107/main
Create Fibonacci_series.java
2 parents 11b772e + 76d9be4 commit be1a4f6

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Fibonacci/Fibonacci_series.java

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

0 commit comments

Comments
 (0)