### Fibonacci golden nuggets题号：137 难度： 50 中英对照

Consider the infinite polynomial series AF(x) = xF1 + x2F2 + x3F3 + ..., where Fk is the kth term in the Fibonacci sequence: 1, 1, 2, 3, 5, 8, ... ; that is, Fk = Fk−1 + Fk−2, F1 = 1 and F2 = 1.

For this problem we shall be interested in values of x for which AF(x) is a positive integer.

 Surprisingly AF(1/2) = (1/2).1 + (1/2)2.1 + (1/2)3.2 + (1/2)4.3 + (1/2)5.5 + ... = 1/2 + 1/4 + 2/8 + 3/16 + 5/32 + ... = 2

The corresponding values of x for the first five natural numbers are shown below.

 x AF(x) √2−1 1 1/2 2 (√13−2)/3 3 (√89−5)/8 4 (√34−3)/5 5

### Code

public final class p137 {
public static void main(String[] args) {
long start=System.nanoTime();
String result = run();
long end=System.nanoTime();
System.out.println(result);
System.out.println( (end-start)/1000000 + "ms" );
}

static public String run(){
int x=15;
long f[]=new long [2*x+3];
f[0]=0;f[1]=1;f[2]=1;
for(int i=3;i<f.length;i++){
f[i]=f[i-1]+f[i-2];
}
return ""+(f[2*x]*f[2*x+1]);
}

}
1120149658760
0ms