class Fib{ static long fib(int n) { assert n >= 0; double s5 = Math.sqrt(5); return (long)((Math.pow((1+s5) / 2, n) - Math.pow((1-s5) / 2, n))/s5); } }