login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A320170 Every pair of consecutive numbers sums to a palindrome, starting with a(0)=1; a(1)=10, and taking a(n) = smallest number > a(n-2). 0

%I #24 Apr 27 2020 02:33:41

%S 1,10,12,21,23,32,34,43,45,54,47,64,57,74,67,84,77,94,87,104,98,114,

%T 108,124,118,134,128,144,138,154,149,164,159,174,169,184,179,194,189,

%U 204,200,214,210,224,220,234,230,244,240,254,251,264,261,274,271

%N Every pair of consecutive numbers sums to a palindrome, starting with a(0)=1; a(1)=10, and taking a(n) = smallest number > a(n-2).

%t Nest[Append[#, Block[{k = #[[-2]] + 1}, While[! PalindromeQ[#[[-1]] + k], k++]; k]] &, {1, 10}, 53] (* _Michael De Vlieger_, Oct 10 2018 *)

%o (Python)

%o CurrentNum=10

%o PreviousNum=1

%o NewNum=0

%o def NextPalindrome(StartNum):

%o FoundNext=0

%o t=0

%o n=0

%o Number=0

%o Lastdigit=0

%o while FoundNext<=PreviousNum:

%o n=n+1

%o t=StartNum+n

%o Number=t

%o Reverse=0

%o while Number>0:

%o Lastdigit=Number%10

%o Reverse=(Reverse*10)+Lastdigit

%o Number=Number//10

%o if t==Reverse:

%o FoundNext=n

%o return n

%o print(1)

%o print(10)

%o for x in range(50):

%o NewNum=NextPalindrome(CurrentNum)

%o print(NewNum)

%o PreviousNum=CurrentNum

%o CurrentNum=NewNum

%Y Cf. A062932.

%Y For n < 10, equals A061870 and A175885.

%K nonn,easy,base

%O 0,2

%A _Jim Singh_, Oct 07 2018

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified March 29 00:26 EDT 2024. Contains 371264 sequences. (Running on oeis4.)