C语言Matrix编程题——[Recursion]D. Liang 8.4 Summing series

[Recursion]D. Liang 8.4 Summing series

Description:

用递归函数计算以下等式
m(i) = 1 + 1/2 + 1/3 + … + 1/i
使用以下函数头
double m(int i)

Input:

正整数n(n<=100)

Output:

输出m(n),结果保留两位小数

Sample Input:

3

Sample Output:

1.83

Hint:

Don’t submit the main() function.

Programme:

//Date:2020/6/12
//Author:Kamenrider Justice
double m(int n)
{
   if(n==1)
   {
      return 1;
   }
   else
   {
      return m(n-1)+1.0/n;
   }
}

8小时Python零基础轻松入门

你可能感兴趣的:(C语言Matrix)