码迷,mamicode.com
首页 > 编程语言 > 详细

1130: 零起点学算法37——求阶乘

时间:2017-04-08 01:03:22      阅读:593      评论:0      收藏:0      [点我收藏+]

标签:format   算法   class   php   http   bit   技术   pre   技术分享   

1130: 零起点学算法37——求阶乘

Time Limit: 1 Sec  Memory Limit: 64 MB   64bit IO Format: %lld
Submitted: 2109  Accepted: 1328
[Submit][Status][Web Board]

Description

输入一个正整数n,计算它的阶乘

 

Input

输入一个正整数n(n<=10)(多组数据)

 

Output

输出n的阶乘(每组数据一行)

 

Sample Input 技术分享

 
3

 

Sample Output

6

 

Source

 1 #include<stdio.h>
 2 int main(){
 3     int n;
 4     while(scanf("%d",&n)!=EOF){
 5          long long num=1;
 6          for(int i=n;i>0;i--){
 7              num*=i;
 8          }
 9          printf("%lld\n",num);
10     }
11     return 0;
12 }

 

1130: 零起点学算法37——求阶乘

标签:format   算法   class   php   http   bit   技术   pre   技术分享   

原文地址:http://www.cnblogs.com/dddddd/p/6680394.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!