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

Create a program which prompts the user for a number. The program then calculate

ID: 3683544 • Letter: C

Question

Create a program which prompts the user for a number. The program then calculates the prime factors of that number USING RECURSION. If you don't use recursion in your program, you will not get credit.

Your program should then output the prime factors in sorted order.

For example, the prime factors for 6 are 2x3.   

For 12, 2 is a prime factor, leaving 6 (2x6=12). So, you could then determine the prime factors of 6, resulting in 2 and 3 as the prime factors. Thus, the factors are 2, 2, 3. This example also gives you a hint regarding a recursive algorithm.

Explanation / Answer

Create a program which prompts the user for a number. The program then calculates the prime factors of that number USING RECURSION

Recursion is the process of defining a problem (or the solution to a problem) in terms of (a simpler version of) itself

example of recursion would be finding the maximum value in a list of numbers. The maximum value in a list is either the first number or the biggest of the remaining numbers.

When we write a number n as a product (n = a x b) then say that a and b are factors of n. The equation n = a x b is called a factorization of n.

For example, 6 is a factor of 12 because 12 = 2 x 6. Also, 3 is a factor of 6 because 6 = 2 x 3. If we put these factorizations together we get 12 = 2 x 6 = 2 x (2x 3) = (2x2)x3 = 4 x 3 and so 3 and 4 are factors of 12.

}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include<stdio.h>
int primecheck(int n); // Function to check if i is prime
int primesum(int n); // Function to sum the values of i that are prime
int main(void) {
int n;
int sum;
printf("Enter a number (> 1): "); //Prompting and scanning user input ,n
scanf("%d",&n);
sum = primesum(n);

}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


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