ispal(n) = my (d=digits(n,2)); d==Vecrev(d) a = vector(10 000) pal = select(ispal, [0..#a]) { for (u=1, #pal, if (pal[u] > #a, break); for (v=u, #pal, if (pal[u] + pal[v] > #a, break); for (w=v, #pal, if (pal[u] + pal[v] + pal[w] > #a, break); if (pal[u] + pal[v] + pal[w], a[pal[u] + pal[v] + pal[w]]++; ); ); ); ); print ("0 1"); \\ 0 = 0 + 0 + 0 for (n=1, #a, print (n " " a[n])) } quit