%I
%S 10917,11907,11997,12987,13977,14967,15957,16947,17937,18927,19917,
%T 20997,21834,21987,22977,23814,23967,23994,24957,25497,25947,25974,
%U 26487,26937,27477,27927,27954,28467,28917,29457,29907,29934,30915
%N Lth order palindromes with L > 2.
%C Let P(m) = m/2 if m is even, m + rev(m) if m is odd, where rev(m) is m's base 10 representation reversed. It is conjectured that any number k eventually cycles when P is repeatedly applied to it. If the cycle has length L, k is called an Lth order palindrome.
%C It has not been proved that every number eventually cycles, but all numbers less than a million do. Palindromes of order L > 2 seem to be quite rare. 10917 is the smallest and has order 7. There are 263 less than 100000 and 7745 less than 1000000.
%C The first number with L > 2 that doesn't end in the same cycle as 10917 is 1000353. Other cycles are known, most of them fairly small, but one has length 327 (starting with 1447132589595).
%C There are an infinite number of different cycles of length 7 because one can insert any number of 9's in the middle of a number in the 7thorder cycle and get a new cycle of length 7  e.g., taking the number 13748625 from the cycle, one can produce another cycle from 13749998625.
%C I believe this is not a straightforward generalization of ordinary palindromes (A002113)  they are not the same as 2ndorder palindromes.  _N. J. A. Sloane_, Jan 01 2004
%D C. A. Pickover, Wonders of Numbers, Adventures in Mathematics, Mind and Meaning, Chapter 58, 'Emordnilap Numbers,' Oxford University Press, N.Y., 2001, pp. 142144.
%e For most numbers, iterating P produces a cycle of length 2: e.g., 121 > 242 > 121 > ...
%e The sequence for 10917 is 10917, 82818, 41409, 131823, 459954, 229977, 1009899, 10998900, 5499450, 2749725, 8029197, 15948405, {66433356, 33216678, 16608339, 109989000, 54994500, 27497250, 13748625} where the numbers in the brackets repeat. There are 7 numbers inside the brackets so 10917 is a 7thorder palindrome.
%t Step[n_] := If[ EvenQ[n], n/2, n + FromDigits[ Reverse[ IntegerDigits[n]]]; cPalHash = 1013; clearArray = Array[{} &, cPalHash]; InsertCheck[n_, a_] := Module[{i = Mod[n, cPalHash] + 1}, a[[i]] = Append[ a[[i]], n]]; SetAttributes[ InsertCheck, HoldRest]; CheckArray[n_, a_] := MemberQ[ a[[Mod[n, cPalHash] + 1]], n]; SetAttributes[ CheckArray, HoldRest]; PalListHelper[n_, cTries_] := Module[ {ch = clearArray}, NestWhileList[ (InsertCheck[ #, ch]; Step[ # ]) &, n, Not[CheckArray[ #, ch]] &, 1, cTries]]; PalList[n_, cTries_] := Module[ {lst, nRemoved, loop}, lst = PalListHelper[n, cTries]; nRemoved = First[ First[ Position[ lst, lst[[ 1]]]]]; loop = Drop[ Take[ lst, {nRemoved, 1}], 1]; Append[ Take[ lst, {1, nRemoved  1}], loop]]; Select[ Range[ 31000], Length[ PalList[ #, 1013][[ 1]]] > 2 &]
%Y Cf. A089605, A006960, A023108, A002113.
%K base,nonn
%O 1,1
%A Darrell Plank (jar_czar(AT)msn.com), Dec 28 2003
%E Edited by _Robert G. Wilson v_ and _N. J. A. Sloane_, Dec 31 2003
