cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A006015 Nim product 2*n.

This page as a plain text file.
%I A006015 M0412 #45 Jul 08 2025 16:40:48
%S A006015 0,2,3,1,8,10,11,9,12,14,15,13,4,6,7,5,32,34,35,33,40,42,43,41,44,46,
%T A006015 47,45,36,38,39,37,48,50,51,49,56,58,59,57,60,62,63,61,52,54,55,53,16,
%U A006015 18,19,17,24,26,27,25,28,30,31,29,20,22,23,21,128,130,131,129,136,138,139
%N A006015 Nim product 2*n.
%C A006015 From _Jianing Song_, Aug 10 2022: (Start)
%C A006015 Write n in quaternary (base 4), then replace each 1,2,3 by 2,3,1.
%C A006015 This is a permutation of the natural numbers; A004468 is the inverse permutation (since the nim product of 2 and 3 is 1). (End)
%D A006015 J. H. Conway, On Numbers and Games. Academic Press, NY, 1976, pp. 51-53.
%D A006015 N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
%H A006015 Alois P. Heinz, <a href="/A006015/b006015.txt">Table of n, a(n) for n = 0..16383</a> (first 1001 terms from R. J. Mathar)
%H A006015 <a href="/index/Ni#Nimmult">Index entries for sequences related to Nim-multiplication</a>
%H A006015 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%F A006015 From _Jianing Song_, Aug 10 2022: (Start)
%F A006015 a(n) = A051775(2,n).
%F A006015 a(n) = 2*n if n has only digits 0 or 1 in quaternary (n is in A000695). Otherwise, a(n) < 2*n.
%F A006015 a(n) = n/3 if n has only digits 0 or 3 in quaternary (n is in A001196). Otherwise, a(n) > n/3.
%F A006015 a(n) = 3*n/2 if and only if n has only digits 0 or 2 in quaternary (n is in A062880). Proof: let n = Sum_i d_i*4^i, d(i) = 0,1,2,3. Write A = Sum_{d_i=1} 4^i, B = Sum_{d_i=3} 4^i, then a(n) = 3*n/2 if and only if 2*A + B = 3/2*(A + 3*B), or A = 7*B. If B != 0, then B is of the form (4*s+1)*4^t, but 7*B is not of this form. So the only possible case is A = B = 0, namely n has only digits 0 or 2. (End)
%p A006015 a:= proc(n) option remember; `if`(n=0, 0,
%p A006015       a(iquo(n, 4, 'r'))*4+[0, 2, 3, 1][r+1])
%p A006015     end:
%p A006015 seq(a(n), n=0..70);  # _Alois P. Heinz_, Jan 25 2022
%t A006015 a[n_] := a[n] = If[n == 0, 0, {q, r} = QuotientRemainder[n, 4]; a[q]*4 + {0, 2, 3, 1}[[r + 1]]];
%t A006015 Table[a[n], {n, 0, 70}] (* _Jean-François Alcover_, May 20 2022, after _Alois P. Heinz_ *)
%o A006015 (PARI) a(n) = my(v=digits(n, 4), w=[0,2,3,1]); for(i=1, #v, v[i] = w[v[i]+1]); fromdigits(v, 4) \\ _Jianing Song_, Aug 10 2022
%o A006015 (Python)
%o A006015 def a(n, D=[0, 2, 3, 1]):
%o A006015     r, k = 0, 0
%o A006015     while n>0: r+=D[n%4]*4**k; n//=4; k+=1
%o A006015     return r
%o A006015 # _Onur Ozkan_, Mar 07 2023
%Y A006015 Row 2 of array in A051775.
%Y A006015 Cf. A004468-A004480, A000695, A062880, A001196.
%K A006015 nonn,easy,look
%O A006015 0,2
%A A006015 _N. J. A. Sloane_
%E A006015 More terms from _Erich Friedman_.