c++编程求1!+2!+3!+....10!的值

[复制链接]
查看11 | 回复2 | 2007-4-20 20:31:52 | 显示全部楼层 |阅读模式
自己可以写个程序算一下SUM=0;k=1;for(int i=1;i 1 ? FacSum((x+1)*(y-1), y-1) : x; } int main() { cout << FacSum(10, 10);}
回复

使用道具 举报

千问 | 2007-4-20 20:31:52 | 显示全部楼层
#includeint f(int n){ if(n)return n*f(n-1); else return 1;}void main(){ int sum=0; for(int i=1;i<=10;i++)sum+=f(i); cout<<"sum="<<sum<<endl; }
回复

使用道具 举报

千问 | 2007-4-20 20:31:52 | 显示全部楼层
#include "stdio.h"#include "conio.h"main(){float n,s=0,t=1;for(n=1;n<=10;n++){
t*=n;
s+=t;}printf("1+2!+3!...+10!=%e\n",s);getch();}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行