首页 > 编程语言 > 详细

c语言用递归求:10的阶乘、100+99+98...+3+2+1的值。

时间:2018-04-01 12:40:48      阅读:415      评论:0      收藏:0      [点我收藏+]
#include <stdio.h>
#include <string.h>
void main(){
    int myfun(int in);
    int  a =myfun(10);
    printf("%d\n", a);
}

int myfun(int in){
    if (in > 1)
        //将下面的*换成+,就可以求100+99+98...+3+2+1的值呢。
        return in * myfun(in-1);
    else
        return 1;
}

 

c语言用递归求:10的阶乘、100+99+98...+3+2+1的值。

原文:https://www.cnblogs.com/airduce/p/8686127.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!