10235  Simply Emirp
Moderator: Board moderators
10235  Simply Emirp
Is there any special case ?
I have got lots of WA.
I have consider many numbers as following:
1000 > 1 not prime
2 > 2 emirp
...etc
I have got lots of WA.
I have consider many numbers as following:
1000 > 1 not prime
2 > 2 emirp
...etc

 Experienced poster
 Posts: 169
 Joined: Wed Oct 31, 2001 2:00 am
 Location: Singapore

 New poster
 Posts: 1
 Joined: Tue Mar 05, 2002 2:00 am

 New poster
 Posts: 5
 Joined: Wed Feb 20, 2002 2:00 am
10235
while(scanf("%d", &x) == 1)
{
if(!prime(x)) printf("%d is not prime.n", x);
else
if(!prime(reverse(x))  x == reverse(x)) printf("%d is prime.n", x);
else printf("%d is emirp.n", x);
}
This is my (main) source code.
Why do I get P.E.?
prime(x)  tests if x is prime
reverse(x)  returns x spelled backwards
{
if(!prime(x)) printf("%d is not prime.n", x);
else
if(!prime(reverse(x))  x == reverse(x)) printf("%d is prime.n", x);
else printf("%d is emirp.n", x);
}
This is my (main) source code.
Why do I get P.E.?
prime(x)  tests if x is prime
reverse(x)  returns x spelled backwards
Hi!
Maybe you will consider this test data...
1  not prime
2  prime
3  prime
4  not prime
5  prime
6  not prime
13  emirp
31  emirp
19  prime
91  not prime (!)
Look especially at the last test case...
Good Luck...
PS.
Maybe you forgot about a dot or made a mistake while writing the output...
Check this
Maybe you will consider this test data...
1  not prime
2  prime
3  prime
4  not prime
5  prime
6  not prime
13  emirp
31  emirp
19  prime
91  not prime (!)
Look especially at the last test case...
Good Luck...
PS.
Maybe you forgot about a dot or made a mistake while writing the output...
Check this

 A great helper
 Posts: 284
 Joined: Thu Feb 28, 2002 2:00 am
 Location: Germany
 Contact:
Look the sample outputs!!!!!
Look the sample outputs!!!!! Does your program puts the end dot? When writing the outputs, be sure not to write the leftleaddings ceros. You could be printing the number as string. When output the solutions, the save way is to handle the numbers as notstring (integer, long integer...) You could have an error in your handling string routine!!!
Bye!
Bye!
Output:
N=130:
Prime: 2, 3, 5, 7, 11, 19, 23, 29
Not prime: 1, 4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 22, 24, 25,26, 27, 28, 30
Emirp: 13, 17
N=9999701000000
Not Prime: 999970, 999971, 999972, 999973, 999974, 999975, 999976, 999977, 999978, 999980, 999981, 999982, 999984, 999985, 999986, 999987, 999988, 999989, 999990, 999991, 999992, 999993, 999994, 999995, 999996, 999997, 999998, 999999, 1000000
Prime: 999979
Emirp: 999983
N=130:
Prime: 2, 3, 5, 7, 11, 19, 23, 29
Not prime: 1, 4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 22, 24, 25,26, 27, 28, 30
Emirp: 13, 17
N=9999701000000
Not Prime: 999970, 999971, 999972, 999973, 999974, 999975, 999976, 999977, 999978, 999980, 999981, 999982, 999984, 999985, 999986, 999987, 999988, 999989, 999990, 999991, 999992, 999993, 999994, 999995, 999996, 999997, 999998, 999999, 1000000
Prime: 999979
Emirp: 999983