I've written a program to calculate fibonacci series, it is working fine for lower values but it is stuck in an infinite loop for higher values. Here is the code,

```
public static BigInteger fib(BigInteger n) {
    // ...
    // ...

    if(n.intValue() == 0){
      return BigInteger.valueOf(0);
    }

    if(n.intValue() == 1){
      return BigInteger.valueOf(1);
    }

    if(n.intValue() > 0){
        return calp(n);
      }
    return caln(n);
  }

  static BigInteger calp(BigInteger n){

    BigInteger prev1 = BigInteger.valueOf(1);
    BigInteger prev2 = BigInteger.valueOf(0);

    int i=2;        
    while(i <= n.intValue()){
            BigInteger curr = BigInteger.valueOf(0);

       curr= curr.add(prev1);
       curr = curr.add(prev2);
      prev2=prev1;
      prev1=curr;
      i++;
    }
    return prev1;
  }

```

For value 1234567, it is stuck in an infinite loop. Can someone explain to me why?