login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

Least k such that n^n + k is a palindrome.
0

%I #8 Dec 15 2017 17:36:29

%S 0,0,6,6,98,8,885,545,4294,1,542971,567942,4985950,34463095,817539359,

%T 3335212865,1825278551,60542888969,351980024812,6758401,

%U 13316726728064,355067132000559,10940544943498235,100371505302529555,98630474467606263

%N Least k such that n^n + k is a palindrome.

%t NextPalindrome[n_] := Block[{l = Floor[Log[10, n] + 1], idn = IntegerDigits[n]}, If[ Union[ idn] == {9}, Return[n + 2], If[l < 2, Return[n + 1], If[ FromDigits[ Reverse[ Take[idn, Ceiling[l/2]]]] FromDigits[ Take[idn, -Ceiling[l/2]]], FromDigits[ Join[ Take[idn, Ceiling[l/2]], Reverse[ Take[idn, Floor[l/2]]]]], idfhn = FromDigits[ Take[idn, Ceiling[l/2]]] + 1; idp = FromDigits[ Join[ IntegerDigits[ idfhn], Drop[ Reverse[ IntegerDigits[ idfhn]], Mod[l, 2]]]]]]]]; f[n_] := Block[{}, If[ FromDigits[ Reverse[ IntegerDigits[n^n]]] == n^n, 0, NextPalindrome[n^n] - n^n]];

%K base,nonn

%O 1,3

%A _Jason Earls_, Jul 24 2003

%E Edited and extended by _Robert G. Wilson v_, Jul 26 2003