Write a program in c to find the prime factors of a given number
1 - Find prime numbers using Sieve of Eratosthenes (you can just find primes numbers <= sqrt(n))
2 - Here is an algorithm to find prime factors
// suppose primes is an array of prime numbers // result is an array which will contains prime factors // i is the current prime , i = 0 while primes[i] < n if n % primes[i] is 0 append primes[i] to result while n % primes[i] is 0 n /= primes[i] // increment i i += 1 if n := 1 append n to result // finnaly the result array will contains prime factors of the number n
3 - Good Luck and happy coding …
hope u understand.All the best.
//Program to accept a number and print its prime factors
printf(“Enter the number\n”);
I couldn’t stop laughing.
Just the right answer for a question like this. Good work @betlista