Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Tugas2 {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- System.out.print("Masukkan berapa deret Fibonacci? ");
- int deret=input.nextInt();
- int bil[]=new int[50];
- int i;
- for (i=1;;i++){
- if(i==1)
- bil[i]=0;
- else if(i==2 || i ==3)
- bil[i]=1;
- else
- bil[i]=bil[i-1]+bil[i-2];
- if(i>deret) break;
- System.out.print(" "+bil[i]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment