
-----------------------------------
illu45
Thu Apr 14, 2005 6:49 pm

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:


var prime1, prime2 : boolean
var counter, number2 : int := 0
var numdiv : int
for number : 3 .. 399
    numdiv := number
    for count : 2 .. (number - 1) %Checking if the number is prime by making sure it has no factors other than 1 and itself
        if number / count mod 1 = 0 then
            prime1 := false
        else
            prime1 := true
        end if
    end for
    loop %Calculating the amount of digits in the number
        exit when numdiv 