You are viewing a single comment's thread. Return to all comments →
Java:
public static BigInteger fibonacciModified(int t1, int t2, int n) { BigInteger n2 = BigInteger.valueOf(t1), n1 = BigInteger.valueOf(t2), fib = BigInteger.ZERO; if (n == 1) { return n2; } if (n == 2) { return n1; } for (int i=3; i <=n; ++i) { fib = n2.add(n1.multiply(n1)); n2 = n1; n1 = fib; } return fib; }
Seems like cookies are disabled on this browser, please enable them to open this website
Fibonacci Modified
You are viewing a single comment's thread. Return to all comments →
Java: