[Problem Description]
Fibonacci sequence is known number of columns
F. [. 1] =. 1,
F. [2] =. 1,
for I>. 3, F. [I] = F. [I-. 1] + F. [I-2]
Fibonacci sequence there is a marked special properties, the ratio after the preceding one, F [i] / F [ i + 1]
be divided in Ben approach gold.
To verify this property, given positive integer N, you calculate F [N] / F [N + 1], and 8 bits are
input format for
positive integers N. (1≤N≤200000000
output format
. FN / FN + 1] Reserved 8 decimal answer.
Sample Input
[Output] Sample
50
Title Analysis: direct hit along the lines subject to
the following code;
Import java.util.Scanner ;
public class cxl {
public static void main(String[] args) {
int N=0;
Scanner input=new Scanner(System.in);
N=input.nextInt();
double F[]=new double[20];
F[1]=1;F[2]=1;
for(int i=3;i<F.length;i++) {
F[i]=F[i-1]+F[i-2];
}
double sum=F[N]*1.0/F[N+1];
System.out.printf("%.8f",sum);//转化为8位小数
}
}
If a better algorithm, please guidance, thank you! ! !