login
Total number of nodes summed over all lattice paths from (0,0) to (n,n) that consist of steps (h,v) with h, v prime or one.
3

%I #15 Apr 05 2021 09:17:57

%S 1,2,5,18,68,244,880,3228,11905,43966,162498,600984,2222776,8218022,

%T 30368708,112162230,414006377,1527214022,5630258676,20744334800,

%U 76387507859,281129870088,1034103899368,3801934437930,13971364199298,51318841190524,188420580871859

%N Total number of nodes summed over all lattice paths from (0,0) to (n,n) that consist of steps (h,v) with h, v prime or one.

%H Alois P. Heinz, <a href="/A308241/b308241.txt">Table of n, a(n) for n = 0..600</a>

%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Lattice_path#Counting_lattice_paths">Counting lattice paths</a>

%p b:= proc(x, y) option remember; `if`(y=0, [1$2], (p-> p+[0, p[1]])(

%p add(add(`if`((h=1 or isprime(h)) and (v=1 or isprime(v)),

%p b(sort([x-h, y-v])[]), 0), v=1..y), h=1..x)))

%p end:

%p a:= n-> b(n$2)[2]:

%p seq(a(n), n=0..30);

%t f[p_List] := p + {0, p[[1]]}; f[0] = 0;

%t b[{x_, y_}] := b[{x, y}] = If[y == 0, {1, 1}, f[

%t Sum[Sum[If[(h == 1 || PrimeQ[h]) && (v == 1 || PrimeQ[v]),

%t b[Sort@{x - h, y - v}], {0, 0}], {v, 1, y}], {h, 1, x}]]];

%t a[n_] := b[{n, n}][[2]];

%t a /@ Range[0, 30] (* _Jean-François Alcover_, Apr 05 2021, after _Alois P. Heinz_ *)

%Y Cf. A000040, A008578, A308240, A308274.

%K nonn

%O 0,2

%A _Alois P. Heinz_, May 16 2019