A171947 P-positions for game of UpMark.
1, 3, 7, 9, 11, 15, 19, 23, 25, 27, 31, 33, 35, 39, 41, 43, 47, 51, 55, 57, 59, 63, 67, 71, 73, 75, 79, 83, 87, 89, 91, 95, 97, 99, 103, 105, 107, 111, 115, 119, 121, 123, 127, 129, 131, 135, 137, 139, 143, 147, 151, 153, 155, 159, 161, 163, 167, 169, 171, 175, 179
Offset: 1
Links
- Reinhard Zumkeller, Table of n, a(n) for n = 1..10000
- Aviezri S. Fraenkel, The vile, dopey, evil and odious game players, Discrete Math. 312 (2012), no. 1, 42-46.
Crossrefs
Programs
-
Haskell
import Data.List (delete) a171947 n = a171947_list !! (n-1) a171947_list = 1 : f [2..] where f (w:ws) = y : f (delete y ws) where y = 2 * w - 1 -- Reinhard Zumkeller, Oct 26 2014
-
Maple
# Maple code for M+1 terms of sequence, from N. J. A. Sloane, Oct 26 2014 m:=1; a:=[m]; M:=100; for n from 1 to M do m:=m+1; if m in a then m:=m+1; fi; c:=2*m-1; a:=[op(a),c]; od: [seq(a[n],n=1..nops(a))];
-
Mathematica
f[n_] := Block[{a = {1}, b = {}, k}, Do[k = 2; While[MemberQ[a, k] || MemberQ[b, k], k++]; AppendTo[a, 2 k - 1]; AppendTo[b, k], {i, 2, n}]; a]; f@ 120 (* Michael De Vlieger, Jul 20 2015 *)
-
Python
def A171947(n): def bisection(f,kmin=0,kmax=1): while f(kmax) > kmax: kmax <<= 1 kmin = kmax >> 1 while kmax-kmin > 1: kmid = kmax+kmin>>1 if f(kmid) <= kmid: kmax = kmid else: kmin = kmid return kmax def f(x): c, s = n+x-1, bin(x-1)[2:] l = len(s) for i in range(l&1,l,2): c -= int(s[i])+int('0'+s[:i],2) return c return bisection(f,n,n) # Chai Wah Wu, Jan 29 2025
Formula
Presumably equal to 2*A003159 + 1. - Reinhard Zumkeller, Oct 26 2014
Comments