Exercise: 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).

I did that, but it is not working:

Code:#include <iostream> using namespace std; int sum = 0; bool prime (int number); bool primeSum (int number); int main() { for (int i = 2; i <= 1000; i++) { if (prime(i)) { if (primeSum(i)) { cout << i << endl; } sum = 0; } } cin.get(); return 0; } bool prime (int number) { for (int i = 2; i < number; i++) { if (number % i == 0) { return false; } } return true; } bool primeSum (int number) { for (int i = 2; i <= number;) { if (number % i == 0) { sum += i; number /= i; i--; } } if (prime(sum)) { return true; } return false; }