#include <stdio.h>
int main() {
int i,n
double sum
printf("n = ")
while(scanf("%d",&n) == 1) {
sum = 0.0
for(i = 5i <= n++i) {
if((i%5 == 0) &&(i%9 == 0)) {
sum += 1.0/i
printf("%d ",i)
}
}
if(sum >0)
printf("\n1 - %d之间满足条件的自然数倒数之和为:%lf\n",n,sum)
printf("\nn = ")
}
printf("\n")
return 0
}
#include <stdio.h>int main(int argc,char **argv)
{
double res = 0
int i = 0
double jishu = 1.0
for(i = 1i <= 10000i++)
{
res += jishu/i
}
printf("1到10000的倒数和为%f",res)
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)