login
Number of 1-dimensional sandpiles with n grains piling up against the wall.
7

%I #28 Mar 11 2022 08:00:58

%S 1,1,1,2,3,5,9,14,24,40,67,112,186,312,520,868,1449,2417,4034,6730,

%T 11229,18735,31254,52143,86989,145119,242096,403871,673751,1123964,

%U 1875014,3127926,5218034,8704769,14521354,24224601,40411595,67414781,112461579,187608762

%N Number of 1-dimensional sandpiles with n grains piling up against the wall.

%C Number of compositions of n where the first part is 1 and the absolute difference between consecutive parts is <=1 (smooth compositions).

%H Seiichi Manyama, <a href="/A291896/b291896.txt">Table of n, a(n) for n = 0..4501</a>

%e The a(6)=9 smooth compositions of 6 are:

%e :

%e : oooooo|

%e :

%e : o|

%e : ooooo|

%e :

%e : o |

%e : ooooo|

%e :

%e : o |

%e : ooooo|

%e :

%e : o |

%e : ooooo|

%e :

%e : oo|

%e : oooo|

%e :

%e : o o|

%e : oooo|

%e :

%e : oo |

%e : oooo|

%e :

%e : o|

%e : oo|

%e : ooo|

%p b:= proc(n, i) option remember; `if`(n=0, 1,

%p add(b(n-j, j), j=max(1, i-1)..min(i+1, n)))

%p end:

%p a:= n-> b(n, 0):

%p seq(a(n), n=0..50); # _Alois P. Heinz_, Sep 05 2017

%t b[n_, i_] := b[n, i] = If[n==0, 1, Sum[b[n-j, j], {j, Max[1, i-1], Min[i+1, n]}]]; a[n_] := b[n, 0]; Table[a[n], {n, 0, 50}] (* _Jean-François Alcover_, May 29 2019, after _Alois P. Heinz_ *)

%o (Python)

%o from sympy.core.cache import cacheit

%o @cacheit

%o def b(n, i): return 1 if n==0 else sum(b(n - j, j) for j in range(max(1, i - 1), min(i + 1, n) + 1))

%o def a(n): return b(n, 0)

%o print([a(n) for n in range(51)]) # _Indranil Ghosh_, Sep 06 2017, after Maple code

%Y Cf. A186085, A291895.

%K nonn

%O 0,4

%A _Seiichi Manyama_, Sep 05 2017