A261131 Number of ways to write n as the sum of 3 positive palindromes.
0, 0, 0, 1, 1, 2, 3, 4, 5, 7, 8, 10, 11, 13, 13, 15, 14, 15, 14, 14, 12, 12, 9, 9, 8, 7, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 5, 8, 7, 7, 7, 7, 7
Offset: 0
Examples
a(28) = 5 since 28 can be expressed in 5 ways as the sum of 3 positive palindromes, namely, 28 = 22+5+1 = 22+4+2 = 22+3+3 = 11+11+6 = 11+9+8.
Links
- Giovanni Resta, Table of n, a(n) for n = 0..10000
- Javier Cilleruelo, Florian Luca, Lewis Baxter, Every positive integer is a sum of three palindromes, arXiv:1602.06208, 2017.
Programs
-
Maple
p:= proc(n) option remember; local i, s; s:= ""||n; for i to iquo(length(s), 2) do if s[i]<>s[-i] then return false fi od; true end: h:= proc(n) option remember; `if`(n<1, 0, `if`(p(n), n, h(n-1))) end: b:= proc(n, i, t) option remember; `if`(n=0, 1, `if`(i<1 or t<1, 0, b(n, h(i-1), t)+b(n-i, h(min(n-i, i)), t-1))) end: a:= n-> (k-> b(n, h(n), k)-b(n, h(n), k-1))(3): seq(a(n), n=0..120); # Alois P. Heinz, Sep 19 2018
-
Mathematica
pal=Select[Range@ 1000, (d = IntegerDigits@ #; d == Reverse@ d)&]; a[n_] := Length@ IntegerPartitions[n, {3}, pal]; a /@ Range[0, 1000] Table[Count[IntegerPartitions[n,{3}],?(AllTrue[#,PalindromeQ]&)],{n,0,90}] (* Requires Mathematica version 10 or later *) (* _Harvey P. Dale, Mar 26 2021 *)
Comments