Fibonacci Numbers

class Fibonacci {

  public static void main (String args[]) {
  
    int low = 1;
    int high = 0;
    
    System.out.println(low);
    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
Last Modified September 4, 1998
Copyright 1997, 1998 Elliotte Rusty Harold
elharo@metalab.unc.edu