public class Fbnc {
public static void main(String[] args) {
int f[]=new int[20];
f[0]=f[1]=1;
for(int i=0;i<18;i++){
f[i+2]=f[i]+f[i+1];
}
for(int i=0;i<20;i++){
if(i%5==0){
System.out.println();
}
System.out.print(f[i]+" ");
}
}
}
運行結果:
1 1 2 3 5
8 13 21 34 55
89 144 233 377 610
987 1597 2584 4181 6765