/*
Namec: base_7.c
Purpose: 求分数序列和
Author: syt
Date: 2016_01_25
*/
#include<stdio.h>
int main()
{
int n, k;
double total = 0, j = 2.0, i = 1.0, temp;
scanf("%d", &n);
for(k = 0; k < n; k++)
{
total += j/i;
temp = i;
i = j;
j = temp + j;
}
printf("%.4f\n", total);
return 0;
}
Namec: base_7.c
Purpose: 求分数序列和
Author: syt
Date: 2016_01_25
*/
#include<stdio.h>
int main()
{
int n, k;
double total = 0, j = 2.0, i = 1.0, temp;
scanf("%d", &n);
for(k = 0; k < n; k++)
{
total += j/i;
temp = i;
i = j;
j = temp + j;
}
printf("%.4f\n", total);
return 0;
}