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.
%I A387361 #15 Aug 29 2025 19:37:57 %S A387361 1,4,34,360,4240,53184,695462,9366968,128974482,1806466376, %T A387361 25649169360,368251171264,5336142742044,77928806182640, %U A387361 1145686661461166,16941028325651416,251769181131306246,3758317957588392856,56324288926707167928,847084621934648027872,12780033173479276354696 %N A387361 Number of 2n-step walks from (0, 0) to (0, 0) on square lattice with winding number zero around (1/2, 1/2). %H A387361 Dan Piponi, <a href="/A387361/a387361.png">A sketch of examples of closed walks on a square lattice with winding number 0 and 1.</a> %e A387361 For n = 2 there are A002894(2) = 36 walks from (0, 0) to (0, 0). One walks around the unit square clockwise, the other counterclockwise, leaving a(2) = 34 with winding number zero. %p A387361 f := proc(x, y, w, n) option remember; %p A387361 if abs(x) + abs(y) > n then return 0 fi; %p A387361 if n = 0 then if w = 0 then return 1 else return 0 fi fi; %p A387361 f(x + 1, y, w, n - 1) + f(x - 1, y, w, n - 1) + %p A387361 f(x, y + 1, ifelse(x < 1 and y = 0, w - 1, w), n - 1) + %p A387361 f(x, y - 1, ifelse(x < 1 and y = 1, w + 1, w), n - 1) end: %p A387361 a := n -> f(0, 0, 0, n): seq(a(n), n = 0..40, 2); # _Peter Luschny_, Aug 29 2025 %t A387361 f[x_,y_,w_,n_]:=f[x,y,w,n]=If[Abs[x]+Abs[y]>n, %t A387361 0, %t A387361 If[n==0,If[w==0,1,0], %t A387361 f[x+1,y,w,n-1]+ %t A387361 f[x-1,y,w,n-1]+ %t A387361 f[x,y+1,If[x<1&&y==0,w-1,w],n-1]+ %t A387361 f[x,y-1,If[x<1&&y==1,w+1,w],n-1]] %t A387361 ]; %t A387361 Table[f[0,0,0,n],{n,0,50,2}] %o A387361 (Python) %o A387361 from functools import lru_cache %o A387361 @lru_cache(maxsize=None) %o A387361 def f(x: int, y: int, w: int, n: int) -> int: %o A387361 if abs(x) + abs(y) > n: %o A387361 return 0 %o A387361 if n == 0: %o A387361 return 1 if w == 0 else 0 %o A387361 return ( %o A387361 f(x + 1, y, w, n - 1) + %o A387361 f(x - 1, y, w, n - 1) + %o A387361 f(x, y + 1, (w - 1) if (x < 1 and y == 0) else w, n - 1) + %o A387361 f(x, y - 1, (w + 1) if (x < 1 and y == 1) else w, n - 1) %o A387361 ) %o A387361 print([f(0, 0, 0, n) for n in range(0, 50, 2)]) %Y A387361 Cf. A002894, A307468. %K A387361 nonn,walk,new %O A387361 0,2 %A A387361 _Dan Piponi_, Aug 27 2025