Computer Science Canada Prime Palindromes |
Author: | illu45 [ Thu Apr 14, 2005 6:49 pm ] | ||
Post subject: | Prime Palindromes | ||
Okay, so... here's the question there's a number between 1 and 399, and you have to check whether or not its a prime palindrome or not. Basically what you have to do is a few things: 1) check it the number is prime 2) flip the number over (123 becomes 321) 3) check to see that the flipped number is prime 4) if it is, the number is a prime palindrome... Here is my code so far... I thik there is an error in my prime checking, but I can't figure out what it is:
|
Author: | Andy [ Thu Apr 14, 2005 6:51 pm ] |
Post subject: | |
instead of making it so complicated, make to functions, one called checkprime and one called checkpalindrome, and just use intstr to turn the number into a string and check for palindrome |
Author: | Martin [ Thu Apr 14, 2005 6:51 pm ] |
Post subject: | |
Isn't this from usaco or something? |
Author: | illu45 [ Thu Apr 14, 2005 6:51 pm ] |
Post subject: | |
martin wrote: Isn't this from usaco or something?
Dunno... my teaher just gave it to me as lab 10b ![]() P.S. Thanks for the quick replies, I'll try that |