Created
October 19, 2015 07:56
-
-
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.
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 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