Datasets:

ArXiv:
License:
File size: 292 Bytes
c574d3a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
public class FibIterative{

  static int fib(int n){

    int a = 0, b = 1,c;

    if(n==0){
      return n;
    }

    for(int i = 2; i<=n;i++){
      c = a+b;
      a = b;
      b = c;
    }
    return b;
  }

  public static void main(String[] args){
    System.out.println(fib(5));
  }
}