Write a function perfect that determines whether a number is a perfect number or not. This function should receive a number and return true if the number is perfect and false otherwise. Use this function in a program that determines and prints all the perfect numbers between 1 and 1000. Print the divisors of each perfect number to confirm that the number is indeed perfect as shown in the sample output below.
An integer is said to be a perfect number if the sum of its divisors, including 1 (but not the number itself), is equal to the number. For example, 6 is a perfect number, because 6 = 1 + 2 + 3.
Perfect integers between 1 and 1000:
6 = 1 + 2 + 3
28 = 1 + 2 + 4 + 7 + 14
496 = 1 + 2 + 4 + 8 + 16 + 31 + 62 + 124 + 248
Recently Asked Questions
- Please answer this: what are the reagents that would result in the product shown in this reaction?
- Which of the following sequences cannot exist for a mRNA. Explain your answer. a. ATTGCC b. UTTCTTT c. AAAAAA d. CCCCC
- Please refer to the attachment to answer this question. This question was created from Diamond Food Inc.