A级数求和
题目链接:
题目描述
已知:S n= 1+1/2+1/3+…+1/n。显然对于任意一个整数K,当n足够大的时候,S n大于K。 现给出一个整数K(1<=k<=15),要求计算出一个最小的n;使得S n>K。
输入描述:
输入k
输出描述:
输出n
示例1
输入
1
输出
2 思路:叠加数列和即可,大于k退出即可
//// Created by HJYL on 2019/8/15.//#include#include #include