**The Program in C to use the suitable function to obtain the prime factors recursively is given below**:

```
#include <stdio.h>
void primeFactors(int n) {
int i;
if (n % 2 == 0) {
printf("%d ", 2);
primeFactors(n / 2);
}
for (i = 3; i <= sqrt(n); i += 2) {
while (n % i == 0) {
printf("%d ", i);
n = n / i;
}
}
if (n > 2)
printf("%d ", n);
}
int main() {
int n;
printf("Enter a number: ");
scanf("%d", &n);
primeFactors(n);
return 0;
}
```

## Output:

Enter a number: 60

2 2 3 5 3 10 3 20

## Pro-Tips**💡**

The program defines a function `primeFactors`

which takes in one parameter, the number ‘n’ for which the prime factors need to be found.

The function uses recursion to find the prime factors of the number. It first checks if the number is divisible by 2,

if yes it prints 2 and recursively calls the function with n/2 as the new number and continues the process until the number is no longer divisible by 2.

Then it uses a for loop to iterate through the numbers starting from 3 till the square root of the number and using while loop it checks if the number is divisible by the current number

and if yes it prints that number and continues the process with n/i as the new number until the number is not divisible by the current number.

If the number is greater than 2 and not divisible by any of the numbers, it prints the number as it’s prime factor.

In the main function, it prompts the user to enter the number and calls the `primeFactors`

function with the entered number as an argument and prints the prime factors.

here’s an example of how the program would work:

```
Enter a number: 60
```

Output:

```
2 2 3 5
```

Explanation: The **prime factors** of 60 are 2, 2, 3 and 5.

The program starts with dividing the number by 2, if possible, and then continues to divide the number by the next prime numbers until the number is no longer divisible

**Learn C-Sharp ↗**

C-sharp covers every topic to learn about C-Sharp thoroughly.

**Learn C Programming ↗**

C-Programming covers every topic to learn about C-Sharp thoroughly.

**Learn C++ Programming↗**

**Learn C++ Programming↗**

C++ covers every topic to learn about C-Sharp thoroughly.