| 1 | initial version |
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)])
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.