f=lambda n,k=2:2/n%-3*(1-k)or f(n+~(k&-k)%-3,k+1)
在线尝试!
背景
每个正整数n都可以唯一地表示为n = 2 o(n) c(n),其中c(n)是奇数。
让⟨a ñ ⟩ N> 0是从挑战规范的序列。
我们声称,对于所有正整数n,o(a 2n-1)是偶数。因为o(a 2n)= o(2a 2n-1)= o(a 2n-1)+1,所以这等同于声称o(a 2n)总是奇数。
假设该要求是错误的,令2m-1为序列的第一个奇数索引,以使o(a 2m-1)为奇数。注意,这使2m成为序列的第一个偶数索引,从而o(a 2m-1)是偶数。
o(a2m-1) is odd and 0 is even, so a2m-1 is divisible by 2. By definition,
a2m-1 is the smallest positive integer not yet appearing in the sequence, meaning that a2m-1/2 must have appeared before. Let k be the (first) index of a2m-1/2 in a.
Since o(ak) = o(a2m-1/2) = o(a2m-1) - 1 is even, the minimality of n implies that k is odd. In turn, this means that ak+1 = 2ak = a2m-1, contradicting the definition of a2m-1.
How it works
yet to come