import java.util.Scanner;
public class Fibonacci {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
System.out.println("輸入數列大小: ");
int a = sc.nextInt();
long [] fin = new long[a];
fin[0] = 1;
fin[1] = 1;
for(int i = 2; i < a; i++){
fin[i] = (fin[i-1] + fin[i-2]);
}
for(long b : fin ){
System.out.print(b + " ");
}
}
}
沒有留言:
張貼留言