Javascript Suppose that m and n are integers and m is nonzer
Javascript:
Suppose that m and n are integers and m is nonzero. Recall that m is called a divisor of n if n 14 mt for some integer t; that is, when m divides n, the remainder is 0. The number m is called a proper divisor of n if m < n and m divides n. A positive integer is called perfect if it is the sum of its positive proper divisors. For example, the positive proper divisors of 28 are 1, 2, 4, 7, and 14, and 1 + 2 + 4 + 7 + 14 14 28. Therefore, 28 is perfect. Write a Java program that does the following:
Takes as input a positive integer and then outputs whether the integer is perfect.
Solution
var n=prompt(\"enter an integer :\");
sum=0;
for(i=1;i<n;i++)
{
if(n%i==0)
sum=sum+i;
}
if(sum==n)alert(\"perfect number\");
else alert(\"not a perfect number\");
