%I
%S 1,16,65,168,345,616,1001,1520,2193,3040,4081,5336,6825,8568,10585,
%T 12896,15521,18480,21793,25480,29561,34056,38985,44368,50225,56576,
%U 63441,70840,78793,87320,96441,106176,116545,127568,139265,151656
%N Number of different words that can be formed from an n X n grid of letters, reading horizontally, vertically or diagonally.
%C Also variance of (i.e., expectation of the square of) area under a random walk with 2n steps whose first return to the origin is at point 2n.  _Henry Bottomley_, Apr 11 2002
%C Also number of numbers to be checked for primality in the n X n generalization of the Gordon Lee puzzle (see A109943).  _Hugo Pfoertner_, Jul 09 2005
%F n^2 + 4*(n+1)*Sum {(nj1); j=0..n1} + 8*Sum {(nkj1); j=0..n2, k=1..n1j}.
%F a(n) = n*(2n1)*(5n2)/3.  _Henry Bottomley_, Apr 11 2002
%e For n=2, from the array
%e ab
%e cd
%e we get 16 words:
%e a,b,c,d,ab,ba,cd,dc,ac,ca,bd,db,ad,da,cb,bc.
%e For n=3, from abc/def/ghi we get 9 of length 1, 40 of length 2, 16 of length 3, a total of 65.
%e Gordon Lee puzzle: In a 3 X 3 matrix ((1 2 3)(4 5 6)(7 8 9)) the following numbers have to be checked: 9 singledigit numbers 1...9;
%e 40 2digit numbers: rowwise 12, 21, 23, 32, 45, 54, 56, 65, 78, 87, 89, 98; columnwise 14, 41, 47, 74, 25, 52, 58, 85, 36, 63, 69, 96; diagonals 15, 51, 59, 95, 48, 84, 26, 62; antidiagonals 35, 53, 57, 75, 24, 42, 68, 86;
%e 16 3digit numbers: 123, 321, 456, 654, 789, 987, 147, 741, 258, 852, 369, 963, 159, 951, 357, 753.
%Y Cf. A109943 [Number of primes in the solution of the Gordon Lee puzzle].
%K nonn
%O 1,2
%A _Felice Russo_
%E More terms from _Hugo Pfoertner_, Jul 09 2005
