1. There is a sequence of fractions:2/1,3/2,5/3,8/5,13/8,21/13... Find the sum of the first 20 items of this sequence。
#include "stdio.h"
#include "stdlib.h"
int main()
{
int n, t, number = 20;
double a = 2, b = 1, s = 0;
for (n = 1; n <= number; n++)
{
s = s + a / b;
t = a;
a = a + b;
b = t;
}
printf("The sum is %.3lfn", s);
printf("nnn");
system("pause");
return 0;
}
2. There is a sequence of fractions:1/3,3/5,5/7,7/9...,Find the sum of the first 10 items of this sequence
#include "stdio.h"
#include "stdlib.h"
int main()
{
int i;
double n = 1, sum = 0;
for (i = 0; i < 10; i++)
{
sum += n / (n + 2);
n = n + 2;
}
printf("nsum=%.3f。n", sum);
printf("nnn"); system("pause")return 0;}



