#2 #p(n): number of possible ways of writing n as a word in 1,2,3 p:=proc(n) option remember: if n=0 then 1: elif n=1 then 1: elif n=2 then 2: else p(n-1)+p(n-2)+p(n-3): fi: end: #{p(n)} is sequence A73 (Tribonacci numbers) in OEIS. ### #3 #f(a,b): number of ways to get to ath St and bth Ave by walking positively on the Manhattan lattice f:=proc(a,b) option remember: if a=0 then 1: elif b=0 then 1: else f(a-1,b)+f(a,b-1): fi: end: #{f(n,n)} is sequence A984 (central binomial coefficients) in OEIS. ### #4 #g(a,b): same as f in (3), but with Broadway as well as the Manhattan lattice g:=proc(a,b) option remember: if a=0 then 1: elif b=0 then 1: elif a=b then g(a-1,b)+g(a,b-1)+g(a-1,b-1): else g(a-1,b)+g(a,b-1): fi: end: #{g(n,n)} is sequence A26671 in OEIS. ### #5 #h(a,b): same as g in (4), but all diagonals taking (a,b) to (a+1,b+1) are allowed h:=proc(a,b) option remember: if a=0 then 1: elif b=0 then 1: else h(a-1,b)+h(a,b-1)+h(a-1,b-1): fi: end: #{h(n,n)} is sequence A1850 (central Delannoy numbers) in OEIS. ###