First time here? Check out the FAQ!

Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

answered 1 year ago

FrédéricC gravatar image

Like this

sage: @cached_function
....: def a(n,k=None):
....:     if k is None: k=n
....:     if n<1: return int(n==0)
....:     return sum(a(n-p,p-1) for p in prime_range(k+1))
....: print([a(n) for n in range(1,50)])