Fibonacci Numbers

class Fibonacci {

  public static void main (String args[]) {
  
    int low = 0;
    int high = 1;
    
    while (high < 50) {
      System.out.println(high);
      int temp = high;
      high = high + low;
      low = temp;
    }
    
  }
   
}

Example

Addition

while loop

Relations

Variable declarations and assignments


Previous | Next | Top | Cafe au Lait

Copyright 1997-2006 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified June 3, 2006