forked from IND-Debugs/Java-Programs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFibo.java
More file actions
30 lines (30 loc) · 714 Bytes
/
Copy pathFibo.java
File metadata and controls
30 lines (30 loc) · 714 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
package Allprogram;
import java.util.Scanner;
public class Fibo {
public int a=0,b=1,i,c,n;
public void fibon(int x)
{
n = x;
if(n==1)
System.out.println(a);
else if(n==2)
{ System.out.println(a+" "+b); }
else
{ System.out.print(a+"\n"+b);
System.out.println();
for(i=3;i<=n;i++)
{
c=a+b;
System.out.println(c);
a=b;
b=c;
} }
}
public static void main(String[] args) {
Fibo obj = new Fibo();
Scanner s = new Scanner(System.in);
System.out.println(" Enter the number");
int c = s.nextInt();
obj.fibon(c);
}
}