Problem: There is a sequence of scores: 2/1, 3/2, 5/3, 8/5, 13/8, 21/13... Find the sum of the first 20 items of this sequence.
public class example1 {
public static void main(String[] args) {
double n=2;
double m=1;
double sum=0.0;
for(int i=0;i<20;i++) {
sum+=n/m;
double temp=n;
n=n+m;
m=temp;
}
System.out.println(sum);
}
}