| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2635 人关注过本帖
标题:N计算阶乘之和?
只看楼主 加入收藏
tianhe
Rank: 1
等 级:新手上路
帖 子:86
专家分:0
注 册:2005-3-17
收藏
 问题点数:0 回复次数:6 
N计算阶乘之和?
如何计算阶乘之和。例:1!+2!+3!+......n!
 我相信每个人的算法都不一样。大家都来动动脑。
搜索更多相关主题的帖子: 之和 阶乘 
2005-03-25 17:46
fokin
Rank: 1
等 级:新手上路
帖 子:49
专家分:0
注 册:2005-3-25
收藏
得分:0 
很简单

我不是高手,我只是新手~!!
2005-03-25 18:41
tianhe
Rank: 1
等 级:新手上路
帖 子:86
专家分:0
注 册:2005-3-17
收藏
得分:0 
using System;
 class xunhuan
 {
static   public long sum=1;
static  public long sumall=1;
 static  void Main()
  {
   Console.WriteLine("Please input max N:");
   int iRead=int.Parse(Console.ReadLine());
   for(int i=2;i<=iRead;i++)
   {
    sum=sum*i;//
    sumall+=sum;
                        
   }
   Console.WriteLine("The result is "+sumall);
  }
 }

-------------------------------------------- 朴素,清醒
2005-03-26 08:11
fokin
Rank: 1
等 级:新手上路
帖 子:49
专家分:0
注 册:2005-3-25
收藏
得分:0 
真的很简单哟!

我不是高手,我只是新手~!!
2005-04-01 16:02
幻风幻云
Rank: 1
等 级:新手上路
帖 子:762
专家分:0
注 册:2005-1-14
收藏
得分:0 
这个算法好

2005-04-01 16:19
yushengou
Rank: 1
等 级:新手上路
帖 子:401
专家分:0
注 册:2005-3-30
收藏
得分:0 
嘎嘎。这个我会咯。不过是和楼主做的差不多。
我是把sumall定义为0的。
然后把i定义为1这样。

我是初学者,希望大家能多多帮助我 /bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://bbs./bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif');}" onmousewheel="return imgzoom(this);" alt="" />
2005-04-02 09:52
zlh1016
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2011-5-15
收藏
得分:0 
            int x = 1;
            int sum = 0;
            for (int i = 1; i <= 15; i++)
            {
                x *= i;
                sum += x;
                Console.WriteLine(x);
            }
            Console.WriteLine(sum);
            Console.ReadKey();
结果为什么是1443297818  结果小于  15的阶乘
2011-06-14 22:15
快速回复:N计算阶乘之和?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016452 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved