Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Javascript: Suppose that m and n are integers and m is nonzero. Recall that m is

ID: 3940022 • Letter: J

Question

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.

Explanation / Answer

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");

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote