-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFibbonacciSeries.java
More file actions
56 lines (42 loc) · 980 Bytes
/
FibbonacciSeries.java
File metadata and controls
56 lines (42 loc) · 980 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package questions2;
import java.util.Scanner;
public class FibbonacciSeries {
//Recurtion
static int fib(int n) {
if( n <= 0 ) {
return 0;
}else if( n == 1 ) {
return 1;
}else {
return ( fib( n - 1 )+ fib( n - 2 ));
}
// Check Fibbonachi or not
public static boolean checkMember(int n){
if(n ==0 || n ==1){
return true;
}
int a=0, b=1;
do{
int c = a;
a= b;
b = c+a;
}while(b < n);
if(b ==n){
return true;
}else{
return false;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter tha Number");
int n= sc.nextInt();
int a=0, b=1;
System.out.print(a+" "+b+" ");
for(int i =0; i<=n-2; i++) {
int c = a+b;
System.out.print(c+" ");
a=b;
b=c;
}
}
}