【c语言】求1~1000的阶乘和数

#include<stdio.h>
long  fun(int n){
    if(n==0){
        return 0;
    }else if(n==1){
        return 1;
    }else{
        return fun(n-1)*n;
    }
}
 long fun1(int t){
     int m;
    long sum=0;
    while(t>0){
        m=t%10;
        sum+=fun(m);
        t=t/10;
    }
    return sum;
}

void main(){
    int i;
    for(i=1;i<1000;i++){
        if(i==fun1(i)){
            printf("%d符合条件\n",i);
        }
    }

}

posted on 2014-12-18 21:40  蜘蛛牛牛  阅读(1236)  评论(0编辑  收藏  举报

导航