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

[Recursion]D. Liang 8.6 Summing series

Description:

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

Input:

正整数n(n<=100)

Output:

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

Sample Input:

1

Sample Output:

0.50

Hint:

Don’t submit the main() function.

Programme:

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

Python大数据搜索

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