
一个强数是一个数字,其中各位数字的阶乘之和等于该数字本身。
示例
- 123!= 1!+2!+3!
=1+2+6 =9
在这个例子中,123不是一个强数,因为各位数字的阶乘之和不等于该数字本身。
- 145!=1!+4!+5!
=1+24+120
=145
在这个例子中,145是一个强数,因为各位数字的阶乘之和等于该数字本身。
2026年数字艺术字分层PSD素材适用于2026数字艺术字设计 本作品提供2026年数字艺术字分层PSD素材的图片会员免费下载,格式为PSD,文件大小为13.2M; 请使用软件Photoshop进行编辑,作品中文字及图均可以通过软件修改和编辑;
我们用以下逻辑来判断给定的数字是否是强数:
while(n){
i = 1,fact = 1;
rem = n % 10;
while(i ",temp);
else
printf("%d is not a strong number<p>",temp);</p>
程序
以下是用于判断给定数字是否为强数的C程序:
在线演示
#include<stdio.h>
int main(){
int n,i;
int fact,rem;
printf("<p>Enter a number : ");
scanf("%d",&n);
printf("</p>
<p>");
int sum = 0;
int temp = n;
while(n){
i = 1,fact = 1;
rem = n % 10;
while(i </p>
<p>",temp);
else
printf("%d is not a strong number</p>
<p>",temp);
return 0;
}</p></stdio.h>
输出
当执行上述程序时,它产生以下结果 −
Run 1: Enter a number : 145 145 is a strong number Run 2: Enter a number : 25 25 is not a strong number










