-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFibo.java
More file actions
30 lines (27 loc) · 692 Bytes
/
Copy pathFibo.java
File metadata and controls
30 lines (27 loc) · 692 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
25
26
27
28
29
30
/**
* Fibo
*/
import java.util.Scanner;
public class Fibo {
//function to calculate fibo:
static public void fibo(int a) {
int x = 0;
int y = 1;
System.out.println("Fibo numbers are: ");
System.out.println("0");
System.out.println("1");
for(int i = 2; i < a; i++) {
int z = x + y;
System.out.println(z);
x = y;
y = z;
}
}
public static void main(String[] args) {
Scanner obj = new Scanner(System.in);
System.out.println("How many fibo number do you want?");
int x = obj.nextInt();
System.out.println();
fibo(x);
}
}