Function Repository Resource:

PalindromicTripleSum

Source Notebook

Compute three palindromic numbers adding to a given integer

Contributed by: Ed Pegg Jr

ResourceFunction["PalindromicTripleSum"][int]

returns three palindromic numbers summing to int.

Details

The Cilleruelo–Luca–Baxter algorithm proves that every positive integer is the sum of three palindromic positive integers.
The three integers comprising the triple sum are returned in decreasing order.

Examples

Basic Examples (2) 

Find three palindromic numbers that sum to 1234567890123456789:

In[1]:=
pal123 = ResourceFunction["PalindromicTripleSum"][1234567890123456789]
Out[1]=

Check the sum:

In[2]:=
Total[pal123]
Out[2]=

Verify they are palindromes:

In[3]:=
PalindromeQ /@ pal123
Out[3]=

Find three palindromic numbers that sum to 112233445566778899:

In[4]:=
ResourceFunction["PalindromicTripleSum"][112233445566778899]
Out[4]=

Verify the sum:

In[5]:=
Total[%]
Out[5]=

Scope (5) 

Find three palindromic numbers summing to more and more digits of π:

In[6]:=
Grid[pipal = Table[ResourceFunction["PalindromicTripleSum"][Round[Pi 10^n]], {n, 6, 15}]]
Out[6]=

Verify:

In[7]:=
Total /@ pipal
Out[7]=

Find three palindromic numbers summing to increasing powers of 8:

In[8]:=
Grid[Table[ResourceFunction["PalindromicTripleSum"][8^n], {n, 6, 15}]]
Out[8]=

Find three palindromic numbers summing to n! for n between 10 and 20:

In[9]:=
Grid[Table[ResourceFunction["PalindromicTripleSum"][n!], {n, 10, 20}]]
Out[9]=

Find three palindromic numbers summing to nn:

In[10]:=
Grid[palnn = Table[ResourceFunction["PalindromicTripleSum"][n^n], {n, 6, 15}]]
Out[10]=

Compute a palindromic triple sum for the input 20,000:

In[11]:=
ResourceFunction["PalindromicTripleSum"][20000]
Out[11]=

Examine the structure in a series of solutions:

In[12]:=
series = Transpose[
   Table[ResourceFunction["PalindromicTripleSum"][20000 + n], {n, 1, 200}]];
Row[ListPlot[#, ImageSize -> 250] & /@ series]
Out[13]=

Version History

  • 1.0.0 – 30 January 2026

Related Resources

License Information