A227691 Winning positions in the Subtract-a-Prime game.
2, 3, 4, 5, 6, 7, 8, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, 29, 30, 31, 32, 33, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 50, 51, 52, 53, 54, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74
Offset: 1
Keywords
Crossrefs
The Grundy numbers of this game are in A014589.
Programs
-
Mathematica
moves[n_] := Table[n - Prime[i], {i, 1, PrimePi[n]}] gana[n_] := gana[n] = If[n < 2, False,! Select[moves[n],!gana[#] &] == {}]; Select[Range[155], gana[#] &]
-
PARI
is(n)=if(isprime(n) || isprime(n-1), return(1)); if(n<15,return(0)); for(k=9,n-1,if(isprime(n-k) && !is(k), return(1))); 0 \\ Charles R Greathouse IV, Nov 13 2013
Comments