Not
seeing a solution in a spreadsheet, and several ill-constructed programs, one
program seemed to work but the ‘non-palindromic’ count had reached a 9- or
10-digit number. With a D3 rating
something was wrong.
The
problem is asking for “a palindrome that is the cube of something not
palindromic”. That was telling me that
I was working with integers, but was I?
Taking that wording at face value I supposed, since
a single digit is considered to be a palindrome 1 cannot be considered as both
it and its root are palindromes. 2
however is the cube of 2^(1/3).
While
searching for palindromic scripts I happened upon something stating that a
certain value was the only known one to generate a palindromic cube, and emphasis on the word cube.
Editing
my listing I the program stopped at the said result: 2201^3
‘
QB64 listing
CLS
DIM SHARED a AS DOUBLE
DIM SHARED k AS DOUBLE
DIM SHARED p$
DIM SHARED p
a = 1
done = 0
DO
k = a
PalTest
IF p = 0 THEN
k = a ^ 3
PalTest
IF p = 1 THEN
done = 1
PRINT a, a ^ 3
PRINT "done"
END IF
END IF
a = a + 1
LOOP WHILE (done <> 1)
SUB PalTest
p = 0
p$ = LTRIM$(STR$(k))
ln = LEN(p$)
b = 1
DO
IF MID$(p$, b, 1) = MID$(p$, ln - b + 1, 1) THEN
p = 1
ELSE
p = 0
END IF
b = b + 1
LOOP WHILE (b < ln AND p <> 0)
END SUB
|
Posted by brianjn
on 2012-06-16 21:19:13 |