login
a(n) = if n<16 then n else a(floor(n/16)) XOR (n mod 16).
21

%I #16 Jan 25 2018 09:34:43

%S 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1,0,3,2,5,4,7,6,9,8,11,10,13,

%T 12,15,14,2,3,0,1,6,7,4,5,10,11,8,9,14,15,12,13,3,2,1,0,7,6,5,4,11,10,

%U 9,8,15,14,13,12,4,5,6,7,0,1,2,3,12,13,14,15,8,9,10,11,5,4,7,6,1,0,3,2,13

%N a(n) = if n<16 then n else a(floor(n/16)) XOR (n mod 16).

%C A very simple hash function for the nonnegative integers.

%C a(A000079(n))=A133145(n); a(A000302(n))=A010685(n); a(A001025(n))=A161452(n); a(A161440(n))=0; a(A161441(n))=1; a(A161442(n))=2; a(A161443(n))=3; a(A161444(n))=4; a(A161445(n))=5; a(A161446(n))=6; a(A161447(n))=7; a(A161448(n))=8; a(A161449(n))=9; a(A161450(n))=10; a(A161451(n))=11; a(A161452(n))=12; a(A161453(n))=13; a(A161454(n))=14; a(A161455(n))=15. - _Reinhard Zumkeller_, Jun 10 2009

%H R. Zumkeller, <a href="/A160700/b160700.txt">Table of n, a(n) for n = 0..10000</a>

%p read("transforms") ;

%p A160700 := proc(n)

%p if n < 16 then

%p n;

%p else

%p XORnos(procname(floor(n/16)),modp(n,16))

%p end if;

%p end proc: # _R. J. Mathar_, Jul 12 2016

%t a[n_] := a[n] = If[n < 16, n, a[Floor[n/16]] ~BitXor~ Mod[n, 16]];

%t Table[a[n], {n, 0, 100}] (* _Jean-François Alcover_, Jan 25 2018 *)

%o (Maxima)

%o load(functs)$

%o A160700(n):=if n<16 then n else logxor(floor(n/16),mod(n,16))$

%o makelist(A160700(n),n,0,60); /* _Martin Ettl_, Nov 05 2012 */

%o (Haskell)

%o import Data.Bits (xor)

%o a160700 n = a160700_list !! n

%o a160700_list = [0..15] ++ map f [16..] where

%o f x = a160700 x' `xor` m :: Int where (x', m) = divMod x 16

%o -- _Reinhard Zumkeller_, Nov 07 2012

%o (PARI) a(n)=my(t=n%16); while(n>15, n>>=4; t=bitxor(t, n%16)); t \\ _Charles R Greathouse IV_, Jan 25 2018

%K nonn,easy

%O 0,3

%A _Reinhard Zumkeller_, Jun 01 2009