Created
October 19, 2015 15:32
-
-
Save anjanaraveendra/6ce7236cf1341be5aa22 to your computer and use it in GitHub Desktop.
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
<script> | |
var a=prompt("Enter a value"); | |
z=a; | |
e = d = 0; | |
while(z > 0) | |
{ | |
e = z % 10; | |
d = d + fact(e); | |
z = parseInt(z/10); | |
} | |
if(d==a) | |
{ | |
alert("Given number is a strong number"); | |
} | |
else { | |
alert("Give number is not a strong number"); | |
} | |
function fact(x) { | |
if(x == 0) { | |
return 1; | |
} | |
if(x < 0 ) | |
{ | |
return undefined; | |
} | |
for(i = x; --i; ) | |
{ | |
x *= i; | |
} | |
return x; | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment