cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A347947 Number of walks on square lattice from (1,n) to (0,0) using steps that decrease the Euclidean distance to the origin and increase the Euclidean distance to (n,1) and that change each coordinate by at most 1.

This page as a plain text file.
%I A347947 #18 Nov 04 2021 11:08:48
%S A347947 1,3,5,24,81,298,1070,3868,13960,50417,182084,657707,2375894,8583264,
%T A347947 31009890,112038032,404803299,1462624643,5284813128,19095564020,
%U A347947 68998567080,249316670981,900876831495,3255230444720,11762504284218,42502963168784,153581776819904
%N A347947 Number of walks on square lattice from (1,n) to (0,0) using steps that decrease the Euclidean distance to the origin and increase the Euclidean distance to (n,1) and that change each coordinate by at most 1.
%C A347947 Lattice points may have negative coordinates, and different walks may differ in length.  All walks are self-avoiding.
%H A347947 Alois P. Heinz, <a href="/A347947/b347947.txt">Table of n, a(n) for n = 0..1000</a>
%H A347947 Alois P. Heinz, <a href="/A347947/a347947.gif">Animation of a(5) = 298 walks</a>
%H A347947 Wikipedia, <a href="https://en.wikipedia.org/wiki/Lattice_path#Counting_lattice_paths">Counting lattice paths</a>
%H A347947 Wikipedia, <a href="https://en.wikipedia.org/wiki/Self-avoiding_walk">Self-avoiding walk</a>
%p A347947 s:= proc(n) option remember;
%p A347947      `if`(n=0, [[]], map(x-> seq([x[], i], i=-1..1), s(n-1)))
%p A347947     end:
%p A347947 b:= proc(l, v) option remember; (n-> `if`(l=[0$n], 1, add((h-> `if`(
%p A347947       add(i^2, i=h)<add(i^2, i=l) and add(i^2, i=v-h)>add(i^2, i=v-l)
%p A347947       , b(h, v), 0))(l+x), x=s(n))))(nops(l))
%p A347947     end:
%p A347947 a:= n-> b([n, 1]$2):
%p A347947 seq(a(n), n=0..30);
%t A347947 s[n_] := s[n] = If[n == 0, {{}}, Sequence @@
%t A347947      Table[Append[#, i], {i, -1, 1}]& /@ s[n-1]];
%t A347947 b[l_, v_] := b[l, v] = With[{n = Length[l]},
%t A347947      If[l == Table[0, {n}], 1, Sum[With[{h = l + x},
%t A347947      If[h.h<l.l && (v-h).(v-h)>(v-l).(v-l), b[h, v], 0]], {x, s[n]}]]];
%t A347947 a[n_] := b[{n, 1}, {n, 1}];
%t A347947 Table[a[n], {n, 0, 30}] (* _Jean-François Alcover_, Nov 04 2021, after _Alois P. Heinz_ *)
%Y A347947 Column (or row) k=1 of A346540.
%K A347947 nonn,walk
%O A347947 0,2
%A A347947 _Alois P. Heinz_, Sep 20 2021