OFFSET
3,1
COMMENTS
See p. 5 of Phillips paper for details.
LINKS
Michael De Vlieger, Table of n, a(n) for n = 3..3326
Reed Phillips and A. J. Hildebrand, The number of optimal strategies in the Penney-Ante game, Integers (2021) Vol. 21, #A27.
Wikipedia, Penney's game
FORMULA
a(3) = 4, a(4) = a(5) = 2, a(n) = 2 * a(n-1) - (-1)^n * a(Floor(n/2)+1) for n >= 6.
MATHEMATICA
Block[{a}, a[3] = 4; a[4] = a[5] = 2; a[n_] := 2 a[n - 1] - (-1)^n*a[Floor[n/2] + 1]; Array[a[#] &, 36, 3]]
(* Second program, faster: *)
Block[{a = {0, 0, 4, 2, 2}}, Do[AppendTo[a, 2 a[[i - 1]] - (-1)^i*a[[Floor[i/2] + 1]]], {i, 6, 38}]; Drop[a, 2]] (* Michael De Vlieger, Jun 04 2021 *)
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Michael De Vlieger, Jun 02 2021
STATUS
approved