题目:求乘积的和以及求级数的和:y = 1 + 1 / 2 + 1 / 3 + 1 / 4… + 1 / n
#include <stdio.h>
int main()
{
double s = 0,i = 0, n = 0;
scanf("%lf", &n);
for (i = 1; i <= n; i++)
{
s = s + 1 / i;
}
printf("%lf", s);
return 0;
}
题目:求乘积的和以及求级数的和:y = 1 + 1 / 2 + 1 / 3 + 1 / 4… + 1 / n
#include <stdio.h>
int main()
{
double s = 0,i = 0, n = 0;
scanf("%lf", &n);
for (i = 1; i <= n; i++)
{
s = s + 1 / i;
}
printf("%lf", s);
return 0;
}