big question in numbers are prime together...

Nov 19, 2014 at 9:37am
hi gentles, i tested a code that doesn't work. and i want you helping for the shortest code quickly. It's maddening me. The code's duty is showing numbers ( less than 20 ) are prime together (two numbers have no parallel multiples ) . And i want you helping for a right code. The output should be like this:
2 and 3
2 and 5
2 and 7
...
18 and 19

thanks much ,if you can help to end it before tommorrow... Can anybody write it??
Last edited on Nov 19, 2014 at 11:57am
Nov 19, 2014 at 10:43am
Well, where is your current code then?
Nov 19, 2014 at 11:01am
i have a wrong and long code that isn't useful i want know everybody can give me a right code to test it.
Nov 19, 2014 at 11:03am
I think it would be more instructive to help you fix what you did wrong, rather than giving you a working solution.
Nov 19, 2014 at 11:06am
We are here not to do your homework. You should try to redo it yourself and if it still won't work, just post again with the code and ask help for specific problem about it :)
Nov 19, 2014 at 12:03pm
your used word was nasty for a young. I am an old chemist that wants to know about any unsolved question in the science. It's not my homework. It was 30 years ago. And i want to compare lenght of your codes for seleceting the shortest.
Young, If you can't please do like a gentleman.not a schoolboy. Have Anybody a code?
Nov 19, 2014 at 12:18pm
my wrong and long code young programmers:

#include <iostream>

using namespace std ;

int main()
{
float i,j;

for ( i = 1 ; i <= 20 ; i++ )

{

for ( j = 1 ; j <= i ; j++ )

{

if ( i % j != 0 && j % i != 0 )
cout << i << " and " << j << endl;
}

}
return 0;

}
Topic archived. No new replies allowed.