%I #32 Jun 19 2020 10:10:12
%S 0,2,4,1,3,10,12,14,11,13,20,22,24,21,23,5,7,9,6,8,15,17,19,16,18,50,
%T 52,54,51,53,60,62,64,61,63,70,72,74,71,73,55,57,59,56,58,65,67,69,66,
%U 68,100,102,104,101,103,110
%N Generalized nim sum n + n in base 5.
%C I.e., double (mod 5) each digit (0->0, 1->2, 2->4, 3->1, 4->3) of the base-5 representation of n).
%C First 5^n terms of the sequence form a permutation s(n) of 0..5^n-1, n >= 1; the number of inversions of s(n) is 3*(25^n-5^n)/20 (i.e., 3, 90, 2325, 58500, 1464375, ...). - _Gheorghe Coserea_, Apr 23 2018
%H Gheorghe Coserea, <a href="/A004515/b004515.txt">Table of n, a(n) for n = 0..15625</a>
%H <a href="/index/Ni#Nimsums">Index entries for sequences related to Nim-sums</a>
%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%F 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.
%t Array[FromDigits[IntegerDigits[#, 5] /. k_ :> Mod[2 k, 5], 5] &, 56, 0] (* _Michael De Vlieger_, Apr 27 2018 *)
%o (PARI)
%o a(n) = my(v=[0,2,4,1,3],b=#v); fromdigits(apply(d->v[d+1], digits(n, b)), b);
%o vector(56, n, a(n-1)) \\ _Gheorghe Coserea_, Apr 23 2018
%Y Inverse permutation: A065256.
%Y a(n) = A065257(n+1)-1 ("Quintal Queens" permutation).
%K nonn,base,look
%O 0,2
%A _N. J. A. Sloane_
|