Perulangan untuk membuat deret fibonacci : public class DeretFibonacci { public static void main(String[] args) { int bil1=0, bil2=1; for (int bil3=0; bil3<=1000; bil3++){ System.out.print(bil1 +" "); bil1=bil1+bil2; bil2=bil1-bil2; // jika ingin memberi batas diberi "if" if (bil1>100){ break; } } } } Hasil running : 0 1 1 2 3 5 8 13 21 34 55 89 |
Senin, 15 April 2013
Deret Fibonacci
Posted on 23.16 by Thinkerboy