Jumping into C++ problems
Hi, I have written the code of the question "Design a program that finds all numbers from 1 to 1000 whose prime factors, when addedtogether, 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."
the code is
Code:
#include <iostream>
using namespace std;
bool isdivisible(int z,int i)
{
return z%i==0;
}
bool (isprime (int z))
{
for (int h=2;h<z;h++)
{
if (isdivisible(z,h))
{
return false;
}
}
return true;
}
int main()
{
for ( int k = 2;k<10; k++)
{
int i=2;
int y=0;
int x;
x=k;
while(i<=x)
{
if (x%i==0)
{
x=x/i;
y=y+i;
}
else
{i++;}
}
int z;
z=x+y-1;
if (isprime(z))
{
cout<<k<<endl;
}
}
}
the problem is that the console window cant display all the results. It omits the 1st few result. How can I increse the space so that it can display all the results?