当前位置:网站首页>Use the for loop to calculate n! Value of

Use the for loop to calculate n! Value of

2022-06-21 22:17:00 Programming expert

source :《 Information Science Olympiad all in one 》p56
【 Title Description 】
utilize for Cycle calculation n! Value .
【 analysis 】
n!=1×2×3×···×n

The code is as follows :

notes : Code for reference only , There is not only one solution .

#include<cstdio>
int main(){
    
 long long s=1;
 int n;
 scanf("%d",&n);
 for(int i=1;i<=n;++i) s*=i;
 printf("%lld",s);
 return 0;
}
原网站

版权声明
本文为[Programming expert]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/172/202206212027390695.html