- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfibo.java
More file actions
Latest commit
22 lines (20 loc) · 592 Bytes
/
Copy pathfibo.java
File metadata and controls
22 lines (20 loc) · 592 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
importjava.util.Scanner;
publicclassfibo {
publicstaticvoidmain(String[] args) {
intfirst = 0;
intsecond = 1;
intnum,total = 0;
Scannerinp = newScanner(System.in);
System.out.println("enter number of terms:");
num = inp.nextInt();
System.out.print(first+" ");
System.out.print(second+" ");
for (inti = 2; i < num; i++) {
total = first + second;
System.out.print(total+ " ");
first = second;
second = total;
}
inp.close();
}
}