Texts: Lab Question 3 - Perfect Number [9 marks]
A positive integer number is said to be a perfect number if its positive factors, including 1 but not the number itself, sum to the number. For example, 6 is a perfect number because 6 = 1 + 2 + 3.
Complete the function int Q3(int Q3_input, int perfect[]) that determines all perfect numbers smaller than or equal to some integer Q3_input (Q3_input > 1).
â—Ź The array perfect[] should hold all the perfect numbers you find. The function should return the total count of perfect numbers you found in the entire calculation process.
Hint: Assuming two positive integers x and y, then x is a factor of y if the remainder of y divided by x is 0. For example, 5 is a factor of 15 because 15 can be evenly divided by 5 with a remainder of 0.
You may optionally provide a flow chart to showcase your understanding for a 0.5 mark bonus.
Lab Question 3 - Perfect Number [9 marks]
A positive integer number is said to be a perfect number if its positive factors, including 1 but not the number itself, sum to the number. For example, 6 is a perfect number because 6 = 1 + 2 + 3.
Complete the function int Q3(int Q3_input, int perfect[]) that determines all perfect numbers smaller than or equal to some integer Q3_input (Q3_input > 1).
The array perfect[] should hold all the perfect numbers you find. The function should return the total count of perfect numbers you found in the entire calculation process.
Hint: Assuming two positive integers x and y, then x is a factor of y if the remainder of y divided by x is 0. For example, 5 is a factor of 15 because 15 can be evenly divided by 5 with a remainder of 0.
You may optionally provide a flow chart to showcase your understanding for a 0.5 mark bonus.