forked from ZoranPandovski/al-go-rithms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ZoranPandovski#23 from jebinphilipose/update-readme
Add Implementation of Strong number and Update README.md accordingly
- Loading branch information
Showing
3 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include<stdio.h> | ||
|
||
int fact(int x) | ||
{ | ||
if(x > 1) | ||
return x*fact(x-1); | ||
else return 1; | ||
} | ||
|
||
int main(void) | ||
{ | ||
int n, t, s=0, r; | ||
printf("Enter the number: "); | ||
scanf("%d", &n); | ||
t=n; | ||
while(t>0) | ||
{ | ||
r = t % 10; | ||
t = t / 10; | ||
s = s + fact(r); | ||
} | ||
(s == n) ? printf("\nThis is a strong number") : printf("\nThis is not a strong number"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
### Strong number | ||
|
||
Strong Numbers are the numbers whose sum of factorial of digits is equal to the original number. Given a number, check if it is a Strong Number or not. | ||
|
||
#### Example: | ||
|
||
Input : 145 <br/> | ||
Output : This is a strong number <br/> | ||
1! + 4! + 5! = 145 |