mirror of
https://github.com/TheAlgorithms/C
synced 2024-11-22 05:21:49 +03:00
Strong number
To check weather a number is strong or not
This commit is contained in:
parent
11fa9a1c5f
commit
3c774575de
29
Strong number
Normal file
29
Strong number
Normal file
@ -0,0 +1,29 @@
|
||||
#include<stdio.h>
|
||||
void strng(int a)
|
||||
{
|
||||
int j=a;
|
||||
int sum=0;
|
||||
int b,i,fact=1;
|
||||
while(a>0)
|
||||
{
|
||||
fact=1;
|
||||
b=a%10;
|
||||
for(i=1;i<=b;i++)
|
||||
{
|
||||
fact=fact*i;
|
||||
}
|
||||
a=a/10;
|
||||
sum=sum+fact;
|
||||
}
|
||||
if(sum==j)
|
||||
printf("%d is a strong number",j);
|
||||
else
|
||||
printf("%d is not a strong number",j);
|
||||
}
|
||||
void main()
|
||||
{
|
||||
int a;
|
||||
printf("Enter the number to check");
|
||||
scanf("%d",&a);
|
||||
strng(a);
|
||||
}
|
Loading…
Reference in New Issue
Block a user