joseleonweb

Untitled

Sep 17th, 2019
138
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Fibonacci {
  2.     /** Print out the Fibonacci sequence for values < 50 */
  3.     public static void main(String[] args) {
  4.         int lo = 1,
  5.             hi = 1;
  6.        System.out.println("Fibonacci sequence until 50");
  7.        System.out.println("---------------------------");
  8.  
  9.        System.out.println(lo);
  10.        while (hi < 50) {
  11.            System.out.println(hi);
  12.            hi = lo + hi;       // new hi
  13.            lo = hi - lo;       /* new lo is (sum - old lo)
  14.                                   that is, the old hi */
  15.        }
  16.     }
  17. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×