OFFSET
0,2
LINKS
Reinhard Zumkeller, Table of n, a(n) for n = 0..10000
FORMULA
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.
From Vladeta Jovovic, Feb 23 2003: (Start)
a(n) = 2*(n - a(floor(n/2))).
a(n) = 2*A063694(n). (End)
a(n) = A088442(n) - 1. - Chris Groer (cgroer(AT)math.uga.edu), Nov 10, 2003
a(n) = n + A053985(n). - Reinhard Zumkeller, Dec 27 2003
a(n) = A063695(2*n+1). - Reinhard Zumkeller, Sep 26 2015
MATHEMATICA
Table[A004514[n], {n, 0, 90}] (* G. C. Greubel, Dec 05 2022 *)
PROG
(Haskell)
a004514 = a063695 . (+ 1) . (* 2) -- Reinhard Zumkeller, Sep 26 2015
(Magma)
function A063694(n)
if n le 1 then return n;
else return 4*A063694(Floor(n/4)) + ((n mod 4) mod 2);
end if; return A063694;
end function;
[A004514(n): n in [0..90]]; // G. C. Greubel, Dec 05 2022
(SageMath)
def A063694(n):
if (n<2): return n
else: return 4*A063694(floor(n/4)) + ((n%4)%2)
[A004514(n) for n in range(91)] # G. C. Greubel, Dec 05 2022
(PARI) a(n) = if(n, bitand(n, 2<<bitor(1, logint(n, 2)) \ 3)) << 1; \\ Kevin Ryde, Dec 10 2022
(Python)
def A004514(n): return (n&((1<<(m:=n.bit_length())+(m&1))-1)//3)<<1 # Chai Wah Wu, Jan 30 2023
CROSSREFS
KEYWORD
base,easy,nonn
AUTHOR
EXTENSIONS
More terms from Reinhard Zumkeller, Dec 27 2003
STATUS
approved