题解 | #牛牛学数列2#
牛牛学数列2
https://www.nowcoder.com/practice/fc72951f52984f3abd286d82eeffacba
#include <stdio.h> int main() { double n = 0; scanf("%lf", &n); //int i = 0; double sum = 0; for(; n>0; n--)//从后向前,省去一个变量 { sum += 1/n; } printf("%.6lf", sum); return 0; }