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.

A004514 Generalized nim sum n + n in base 4.

This page as a plain text file.
%I A004514 #41 Jul 01 2025 19:26:58
%S A004514 0,2,0,2,8,10,8,10,0,2,0,2,8,10,8,10,32,34,32,34,40,42,40,42,32,34,32,
%T A004514 34,40,42,40,42,0,2,0,2,8,10,8,10,0,2,0,2,8,10,8,10,32,34,32,34,40,42,
%U A004514 40,42,32,34,32,34,40,42,40,42,128,130,128,130,136,138,136,138,128
%N A004514 Generalized nim sum n + n in base 4.
%C A004514 In the base 4 expansion of 2*n + 1, change 1 to 0 and 3 to 2. - _Paolo Xausa_, Feb 27 2025
%H A004514 Reinhard Zumkeller, <a href="/A004514/b004514.txt">Table of n, a(n) for n = 0..10000</a>
%H A004514 <a href="/index/Ni#Nimsums">Index entries for sequences related to Nim-sums</a>
%F A004514 Generalized nim sum m + n in base q: write m and n in base q and add mod q with no carries, e.g., 5 + 8 in base 3 = "21" + "22" = "10" = 1.
%F A004514 From _Vladeta Jovovic_, Feb 23 2003: (Start)
%F A004514 a(n) = 2*(n - a(floor(n/2))).
%F A004514 a(n) = 2*A063694(n). (End)
%F A004514 a(n) = A088442(n) - 1. - Chris Groer (cgroer(AT)math.uga.edu), Nov 10 2003
%F A004514 a(n) = n + A053985(n). - _Reinhard Zumkeller_, Dec 27 2003
%F A004514 a(n) = A063695(2*n+1). - _Reinhard Zumkeller_, Sep 26 2015
%F A004514 a(n) = Sum_{k>=0} A030308(n,k)*A103424(k+1). - _Philippe Deléham_, Jan 12 2023
%t A004514 A004514[n_]:= A004514[n]= If[n==0, 0, 2*n -2*A004514[Floor[n/2]]];
%t A004514 Table[A004514[n], {n,0,90}] (* _G. C. Greubel_, Dec 05 2022 *)
%t A004514 A004514[n_] := FromDigits[ReplaceAll[IntegerDigits[2*n + 1, 4], {1 -> 0, 3 -> 2}], 4];
%t A004514 Array[A004514, 100, 0] (* _Paolo Xausa_, Feb 27 2025 *)
%o A004514 (Haskell)
%o A004514 a004514 = a063695 . (+ 1) . (* 2)  -- _Reinhard Zumkeller_, Sep 26 2015
%o A004514 (Magma)
%o A004514 function A063694(n)
%o A004514   if n le 1 then return n;
%o A004514   else return 4*A063694(Floor(n/4)) + ((n mod 4) mod 2);
%o A004514   end if; return A063694;
%o A004514 end function;
%o A004514 A004514:= func< n | 2*A063694(n) >;
%o A004514 [A004514(n): n in [0..90]]; // _G. C. Greubel_, Dec 05 2022
%o A004514 (SageMath)
%o A004514 def A063694(n):
%o A004514     if (n<2): return n
%o A004514     else: return 4*A063694(floor(n/4)) + ((n%4)%2)
%o A004514 def A004514(n): return 2*A063694(n)
%o A004514 [A004514(n) for n in range(91)] # _G. C. Greubel_, Dec 05 2022
%o A004514 (PARI) a(n) = if(n, bitand(n, 2<<bitor(1,logint(n,2)) \ 3)) << 1; \\ _Kevin Ryde_, Dec 10 2022
%o A004514 (Python)
%o A004514 def A004514(n): return (n&((1<<(m:=n.bit_length())+(m&1))-1)//3)<<1 # _Chai Wah Wu_, Jan 30 2023
%Y A004514 Cf. A053985, A063694, A063695, A088442.
%K A004514 base,easy,nonn
%O A004514 0,2
%A A004514 _N. J. A. Sloane_
%E A004514 More terms from _Reinhard Zumkeller_, Dec 27 2003