package array;
import java.util.Scanner;
public class fibo {
public static void main(String a[]){
int count;
System.out.println("Enter the value how many element want in fibonacci series");
Scanner sc=new Scanner(System.in);
count=sc.nextInt();
int fibo[] = new int[count];
fibo[0] = 0;
fibo[1] = 1;
for(int i=2; i < count; i++){
fibo[i] = fibo[i-1] + fibo[i-2];
}
for(int i=0; i< count; i++){
System.out.print(fibo[i] + " ");
}
}
}
import java.util.Scanner;
public class fibo {
public static void main(String a[]){
int count;
System.out.println("Enter the value how many element want in fibonacci series");
Scanner sc=new Scanner(System.in);
count=sc.nextInt();
int fibo[] = new int[count];
fibo[0] = 0;
fibo[1] = 1;
for(int i=2; i < count; i++){
fibo[i] = fibo[i-1] + fibo[i-2];
}
for(int i=0; i< count; i++){
System.out.print(fibo[i] + " ");
}
}
}
No comments:
Post a Comment