login
Numbers k such that (k-1)^2 + k^2 + (k+1)^2 is a palindrome.
0

%I #37 Sep 08 2022 08:46:06

%S 0,1,5,12,38,567,1737,8340,16085,17553,17933,36998,40442,119812,

%T 173737,378812,1328121,1751497,1775707,4427781,8211880,17909283,

%U 40439558,441564381,828223250,5602945243,8227749490,12900321392,16028474345,17552348197,37196982752

%N Numbers k such that (k-1)^2 + k^2 + (k+1)^2 is a palindrome.

%C Indices of the palindromes in A005918.

%H Erich Friedman, <a href="https://erich-friedman.github.io/numbers.html">What's Special About This Number?</a> (See entries 1737, 8340.)

%e 567 is in the sequence because 566^2 + 567^2 + 568^2 = 964469 is a palindrome.

%t palindromeQ[n_] := (id = IntegerDigits[n]) === Reverse[id]; Reap[For[n = 0, n < 10^9, n++, If[palindromeQ[(n-1)^2 + n^2 + (n+1)^2], Print[n]; Sow[n]]]][[2, 1]] (* _Jean-François Alcover_, Dec 03 2013 *)

%t Select[Range[0,10^6],PalindromeQ[(#-1)^2+#^2+(#+1)^2]&] (* The program generates the first 16 terms of the sequence. To generate more, increase the Range constant. *) (* _Harvey P. Dale_, Feb 15 2022 *)

%o (PARI) isok(n) = v = Vec(Str((n-1)^2 + n^2 + (n+1)^2)); v == Vecrev(v); \\ _Michel Marcus_, Dec 03 2013

%o (Python)

%o a = 0

%o while a < 10000000000:

%o ....q = (a-1)**2 + a**2 + (a+1)**2

%o ....if str(q) == str(q)[::-1]:

%o ........print(a,q)

%o ....a+=1

%o # _David Consiglio, Jr._, Sep 12 2014

%o (Magma) [n: n in [0..2*10^7] | Intseq(3*n^2+2, 10) eq Reverse(Intseq(3*n^2+2, 10))]; // _Vincenzo Librandi_, Jul 17 2015

%Y Cf. A002113, A005918.

%K nonn,base

%O 1,3

%A _Bruno Berselli_, Dec 03 2013

%E a(24)-a(25) from _Jean-François Alcover_, Dec 03 2013

%E a(26)-a(27) from _David Consiglio, Jr._, Sep 12 2014

%E a(28)-a(31) from _Lars Blomberg_, Jan 04 2016