mirror of
https://github.com/renbaoshuo/202401-programming-assignments.git
synced 2024-12-16 15:44:39 +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;
|
|
}
|