brilliant_moves

FibonacciYahoo3.java

Dec 12th, 2015
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.38 KB | None | 0 0
  1. public class FibonacciYahoo3 {
  2.  
  3.     static int a = 0, b = 1;
  4.  
  5.     static void next() {
  6.         int temp = a + b;
  7.         a = b;
  8.         b = temp;
  9.     } // next()
  10.  
  11.     public static void main (String[] args) {
  12.         for (int i = 1; i <= 5; i++) {
  13.             for (int j = 0; j < i; j++) {
  14.                 System.out.print(a + " ");
  15.                 next();
  16.             } // for j
  17.             System.out.println();
  18.         } // for i
  19.     } // main()
  20.  
  21. } // class
Add Comment
Please, Sign In to add comment