%I #14 Apr 05 2021 09:18:17
%S 1,2,5,15,47,147,469,1531,5076,17014,57537,196043,671980,2314592,
%T 8005266,27784114,96720440,337572161,1180869043,4139120434,
%U 14534125630,51116699820,180036470572,634925138580,2241803318605,7923931456994,28035799832528,99284104334614
%N Total number of nodes summed over all lattice paths from (0,0) to (n,n) that do not go above the diagonal x=y and consist of steps (h,v) with h, v prime or one.
%H Alois P. Heinz, <a href="/A308274/b308274.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)) and
%p (x-h<=y-v), b(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 x-h <= y-v, b[{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, A308241, A308273.
%K nonn
%O 0,2
%A _Alois P. Heinz_, May 17 2019
|