How to check whether a integer of type mpz_t is a palindrome

Zimmermann Paul Paul.Zimmermann at
Thu Feb 16 12:42:10 CET 2012


>    1. For even n, are all palindromes in any base d divisible by 11? (I
>    know that for d=10 this is true, I ran some quick tests and it seemed to be
>    true for d=8 and d=16, though I cannot be sure)

this is clearly wrong for 11 in base 10. For example in base 8 consider 9
which is a palindrome (1*8+1), but is not divisible by 11. In base d however
any palindrome of even length is divisible by d+1, since you can write it
as a sum of k*d^i+k*d^j for i-j odd, which is divisible by d^(i-j)+1, which
is divisible by d+1.

Paul Zimmermann

More information about the gmp-discuss mailing list