//  Data Structures with Java by John R. Hubbard
//  Copyright McGraw-Hill, 2001
//  Problem 4.13 on page 85
//  Iterative implementation of the Fibonacci function

public class Pr0413
{ public static void main(String[] args)
  { for ( int i = 0 ; i < 15 ; i++ )
    {  int fI = fib(i) ;
       System.out.println("fib("+i+") = " + fI);
    }
  } 
  public static int fib(int n)
  {  if (n< 2) return n ;
     int f0 = 0, f1 = 1, fI = 1 ;
     for ( int i=3; i<=n; i++)
     { f0 = f1 ;
       f1 = fI ;
       fI = f0 + f1 ;
     }
     return fI;
  }
}
