Code:

/*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.*/
#include <iostream>
using namespace std;
int primes(int n);
bool isPrime(int divisor);
bool check(int result);
int main()
{
// Check numbers from 1 to 1000
for (int i = 2; i <= 1000; ++i)
{
int result = primes(i);
if (check(result))
{
cout << i << endl;
}
}
}
bool isPrime(int divisor)
{
for (int j = 2; j <= divisor/2; j++)
{
if (divisor % j == 0)
return false;
}
return true;
}
int primes(int i)
{
int p = i;
int divisor = 2;
int sum = 0;
while (p != 1)
{
cout << "p: " << p << endl;
cout << "le divisor: " << divisor << endl;
if (isPrime(divisor))
{
if (p % divisor == 0)
{
p = p / divisor;
sum += divisor;
}
else
{
divisor += 1;
}
}
}
return sum;
}
bool check(int result)
{
for (int i = 2; i <= result / 2; i++)
{
if (result % i == 0)
return false;
}
return true;
}

My code does not do what is asked.

**Could anyone check it up?**