Design a program that finds all numbers from 1 to 1000 whose prime factors, when added

together, sum up to a prime number (for example, 12 has prime factors of 2, 2, and 3, which

sum to 7, which is prime). Implement the code for that algorithm.

Here’s the algorithm with the code for finding out the prime factors of a number:-

- Incorporate the above algorithm.
- sum+=prime_factor
- For i=1 to sizeof(A)

if (sum == A[i])

/*store all the prime numbers up till 997 (using Sieve of Eratosthenes :*/

http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes ) in an array A.

print number

It can be solved much faster for much larger limits, since products of prime numbers increase very very quickly. Even with just a backtrack over all subsets of prime numbers.