Question: Write a C ++ function, void factors(int n, int facts[]), to populate the array facts to indicate what the factors of n are. For instance,
Write a C ++ function, void factors(int n, int facts[]), to populate the array facts to indicate what the factors of n are. For instance, since the factors of 6 are 1, 2, 3, and 6, the facts array for 6 would be spot = [0, 1, 2, 3, 4, 5, 6] / value = {0, 1, 1, 1, 0, 0, 1}.
Now, write a function bool isperfect(int n, int factors[]) that returns true if n is perfect, and false if it isnt. Mathematically, a number is perfect if it equals the sum of its factors (not including itself). So 6 is perfect because 1+2+3 = 6. However, 4 is not perfect because the factors of 4 are 1 and 2, and 1+2 != 4
Use the main function below:
int main(){ int a[50]; int test = 0; cout<<"Enter a number!"<
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
