求阶乘,输入一个正整数 n,输出n!
生活随笔
收集整理的這篇文章主要介紹了
求阶乘,输入一个正整数 n,输出n!
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
#include<stdio.h>
int factorial (int n);
int main(){
int n;
scanf("%d",&n);
printf("%d \n",factorial(n));
return 0;
}
int factorial(int n){
int i,fact=1;
for(i=1;i<=n;i++)
fact = fact*i;
return fact;
}
轉載于:https://www.cnblogs.com/geyang/p/6931973.html
總結
以上是生活随笔為你收集整理的求阶乘,输入一个正整数 n,输出n!的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql数据库切换
- 下一篇: BZOJ 2427 软件安装(强连通分量