2022级统计计算机双学位《程序设计原理与C语言》上机作业

1043. Compute

单点时限: 2.0 sec

内存限制: 512 MB

Write a RECURSIVE function to compute the following formula:

sum(n)=112+1314+(1)n1n

/***************************************************************/
/*                                                             */
/*  DON'T MODIFY main function ANYWAY!                         */
/*                                                             */
/***************************************************************/
#include <stdio.h>
double sum(int n)
{

 // TODO: your function definition

}
int main()
{
    int n;
    scanf("%d",&n);
    printf("%f\n",sum(n));
    return 0;
}

样例

Input
29358
Output
0.693130
Input
1
Output
1.000000
Input
3
Output
0.833333