Skip to content

Instantly share code, notes, and snippets.

@anjanaraveendra
Created October 19, 2015 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anjanaraveendra/6ce7236cf1341be5aa22 to your computer and use it in GitHub Desktop.
Save anjanaraveendra/6ce7236cf1341be5aa22 to your computer and use it in GitHub Desktop.
<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