forked from ishanjogalekar/Java-Programs
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path5.Fibonacci.java
More file actions
Latest commit
24 lines (22 loc) · 575 Bytes
/
Copy path5.Fibonacci.java
File metadata and controls
24 lines (22 loc) · 575 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Question - Fibonacci Series in Java.
//Code-
importjava.util.*;
importjava.math.*;
publicclassBasic_codes {
publicstaticvoidmain(String[] args) {
Scanners = newScanner(System.in);
intn1=0,n2=1;
System.out.println("Enter the number of terms in fibonacci series: ");
intn = s.nextInt();
System.out.println(n1+","+n2);
while (n>2){
intc;
c = n1+n2;
System.out.println(","+c);
n1 = n2;
inta;
n2 = c;
n-=1;
}
}
}