Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f9747bf

Browse files
Create PrintFibonacciSeries.java
1 parent 25e620e commit f9747bf

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

‎src/PrintFibonacciSeries.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
public class PrintFibonacciSeries {
2+
3+
public static void printFibonacciSeries(int count) {
4+
int a = 0;
5+
int b = 1;
6+
int c = 1;
7+
for (int i = 1; i <= count; i++) {
8+
System.out.print(a + ", ");
9+
a = b;
10+
b = c;
11+
c = a + b;
12+
}
13+
}
14+
15+
public static void main(String args[]) {
16+
17+
// don't exceed it hehe
18+
printFibonacciSeries(40);
19+
20+
}
21+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /