Skip to content

Commit

Permalink
Create strong number.c
Browse files Browse the repository at this point in the history
  • Loading branch information
SrijanZ authored Oct 21, 2020
1 parent 91884fc commit 08d4cc4
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions strong number.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <stdio.h>
int factorial(int r) {
int fact = 1;
while(r>1) {
fact = fact * r;
r--;
}
return fact;
}
int check(int n) {
int temp, rem, result = 0;
temp = n;
while(temp) {
rem = temp % 10;
result = result + factorial(rem);
temp = temp/10;
}
if (result == n)
return 1;
else
return 0;
}
int main(int argc, char const *argv[]) {
int n = 145;
if (check(n))
printf("Yes it is a strong number\n");
else
printf("no it is not a strong number\n");
return 0;
}

0 comments on commit 08d4cc4

Please sign in to comment.