SHARE
TWEET

Untitled

a guest Mar 18th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.stanley.tugas1;
  2.  
  3. public class TugasFibonacci {
  4.  
  5.     public TugasFibonacci() {
  6.         // TODO Auto-generated constructor stub
  7.         generateFibonacci(10);
  8.     }
  9.    
  10.     void generateFibonacci(int n) {
  11.         int now = 0;
  12.         int then = 1;
  13.         for (int x=0; x<n; ++x) {
  14.             if (x%2==0) {
  15.                 System.out.print(now + " ");
  16.                 now += then;
  17.             } else {
  18.                 System.out.print(then + " ");
  19.                 then += now;
  20.             }
  21.         }
  22.     }
  23.    
  24.     public static void main(String args[]) {
  25.         new TugasFibonacci();
  26.     }
  27.  
  28. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top