首页 > 其他 > 详细

刚刚学了循环,1到n的求和与阶乘

时间:2016-04-16 17:01:16      阅读:242      评论:0      收藏:0      [点我收藏+]


//求和
int a = Convert.ToInt32(Console.ReadLine());
int c = 0;
for (int b = 0; b <= a; b++)
{
c = c + b;

}
Console.Write(c);

 

//阶乘
int a = Convert.ToInt32(Console.ReadLine());
int end = 1;
for (int b=1; b<=a;b++ )
{
end = end * b;

}
Console.Write(end);

刚刚学了循环,1到n的求和与阶乘

原文:http://www.cnblogs.com/zzc134680/p/5398430.html

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