Skip to content

Commit 0fff0fb

Browse files
authored
Merge pull request codec-akash#26 from ashumau845/master
Added Fibonacci Series Program
2 parents 890c031 + e148568 commit 0fff0fb

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

Fibonacci.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import java.util.*;
2+
public class Fibonacci {
3+
4+
public static void main(String[] args) {
5+
6+
int n , t1 = 0, t2 = 1;
7+
System.out.println("Please Input your number to print Fibonacci Series");
8+
9+
Scanner sc= new Scanner(System.in);
10+
n= sc.nextInt();
11+
System.out.print("First " + n + " terms: ");
12+
13+
14+
for (int i = 1; i <= n; ++i)
15+
{
16+
System.out.print(t1 + " ");
17+
18+
int sum = t1 + t2;
19+
t1 = t2;
20+
t2 = sum;
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)