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

A perfect number is a positive integer that is equal to the sum of its proper di

ID: 3788617 • Letter: A

Question

A perfect number is a positive integer that is equal to the sum of its proper divisors. A proper divisor is a positive integer other than the number itself that divides the number evenly (i.e., no remainder). For example, 6 is a perfect number because the sum of its proper divisors 1, 2, and 3 is equal to 6. Eight is not a perfect number because 1 +2 + 4 notequalto 8. Write a program that accepts a positive integer and determines whether the number is perfect. Also display all proper divisors of the number. Try a number between 20 and 30 and another number between 490 and 500. Write a program that displays all integers between low and high that are the sum of the cube of their digits. In other words, find all numbers xyz such that xyz = x^3 + y^3 + z^3 for example 153 = 1^3 + 5^3+ 3^3. Try 100 for tow and 1000 for high.

Explanation / Answer

Required solution:

#include <stdio.h>

int main(void) {
int number, i, sum=0;
printf("Enter the number:");
scanf("%d",&number);
printf("Proper divisors are: ");
for(i=1; i<number; i++)
{
if(number % i == 0){
printf("%d ",i);
sum+=i;
}
}
if(sum == number){
printf(" %d is perfect number",number);
}
else{
printf(" %d is not a perfect number",number);
}
   return 0;
}

Sample test case:1(Between 490 and 500)

Enter the number:496

Proper divisors are:
1
2
4
8
16
31
62
124
248

496 is perfect number

Sample test case:1(Between 20 and 30)

Enter the number:28

Proper divisors are:
1
2
4
7
14

28 is 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