Skip to content

Instantly share code, notes, and snippets.

@anjanaraveendra
Created October 19, 2015 07:56
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/df5eb746f919064249c2 to your computer and use it in GitHub Desktop.
Save anjanaraveendra/df5eb746f919064249c2 to your computer and use it in GitHub Desktop.
1. Write a JS program to check given number is perfect number or not.
<script>
var input=prompt("Enter a value");
var v=input;
var count=0;
for(var i=1; i<input; i++)
{
if(input%i==0)
{
count=count+i;
}
}
if(count==v)
{
alert("given no is perfect");
}
else
{
alert("given no is not a perfect");
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment