-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFibJava.java
More file actions
22 lines (18 loc) · 484 Bytes
/
FibJava.java
File metadata and controls
22 lines (18 loc) · 484 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package fibjava;
import java.util.Scanner;
public class FibJava {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Enter the max value of the Fibionacci sequence to display: ");
int i = input.nextInt();
int x = 0;
int y = 1;
int z = 0;
while (x + y <= i) {
x += y;
z = y;
y = x;
System.out.println(x);
}
}
}