mirror of
https://github.com/renbaoshuo/202401-programming-assignments.git
synced 2024-11-23 15:48:42 +00:00
21 lines
273 B
C
21 lines
273 B
C
#include <stdio.h>
|
|
|
|
int main() {
|
|
int n;
|
|
|
|
scanf("%d", &n);
|
|
|
|
double a = 2, b = 1, sum = 0;
|
|
|
|
for (int i = 1; i <= n; i++) {
|
|
sum += a / b;
|
|
double temp = a;
|
|
a = a + b;
|
|
b = temp;
|
|
}
|
|
|
|
printf("%.6lf\n", sum);
|
|
|
|
return 0;
|
|
}
|