Skip to content

Commit

Permalink
Merge pull request ZoranPandovski#23 from jebinphilipose/update-readme
Browse files Browse the repository at this point in the history
Add Implementation of Strong number and Update README.md accordingly
  • Loading branch information
ZoranPandovski authored Oct 1, 2017
2 parents 35026e5 + c073d78 commit 803811d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Clean examples implementations of data structures and algorithms written in diff
* [russian peasant](math/russian_peasant)
* [towers_of_hanoi](math/towers_of_hanoi)
* [armstrong_number](math/armstrong_number)
* [strong_number](math/strong_number)
* [Cryptography](cryptography)
* [caesar cipher](cryptography/caesar_cipher)
* [substitution cipher](cryptography/substitution_cipher)
Expand Down
23 changes: 23 additions & 0 deletions math/strong_number/C/strong.c
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");
}
9 changes: 9 additions & 0 deletions math/strong_number/README.md
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

0 comments on commit 803811d

Please sign in to comment.