Jumat, 14 Oktober 2011

Deret bilangan Fibonacci

class Cakra2{
public static void main (String [] args) {
int x = Integer.parseInt(args[0]);

int i, temp01, temp02, hasil;
temp01=0;
temp02=1;
hasil=0;

for(i=1; i<=x; i++){
temp01=temp02;
temp02=hasil;
System.out.print(hasil+" ");
hasil=temp01+temp02;
}
}
}
output

Tidak ada komentar:

Posting Komentar