Wednesday, 7 January 2015

Contoh script array input deret fibonacci

public class Array
{
            public static void main(String[]args)
            {
                        int a=1, b=1;
                        int n = 5; // input deret fibonacci

                        System.out.print(a+" ");
                        for (int i=1; i<n; i++) // menggunakan perulangan for
                        {
                                    System.out.print(a+" ");
                                    a= a+b;
                                    b= a-b;
                        }
                        System.out.println();
            }
}




Download script Link1 / Link2

No comments:

Post a Comment