%I #38 May 04 2023 15:32:12
%S 0,0,3,1,5,3,8,4,9,7,12,8,14,10,17,11,17,15,20,16,22,18,25,19,26,22,
%T 29,23,31,25,34,26,33,31,36,32,38,34,41,35,42,38,45,39,47,41,50,42,50,
%U 46,53,47,55,49,58,50,59,53,62,54,64,56,67,57,65,63,68,64,70,66,73,67,74,70,77,71,79,73,82,74,82,78,85,79,87,81,90,82,91,85
%N If n is even, then a(n) = n + bitsum(n), else a(n) = n - bitsum(n), where bitsum(n) is the count of binary 1's in n, A000120.
%C I gathered together some interesting statistics for this seq A227361:
%C Within the first 200000001 members of this sequence, only 70 were repeated 4 times, and then only when n > 2 million. None were repeated 5 times.
%C The first value to become repeated 3 times is 50, occurring at indexes (n=) 46, 48, and 55.
%C The first value to become repeated 4 times is 2097170, occurring at indexes (n=) 2097150, 2097166, 2097168, and 2097175.
%C The total count of those only occurring once is 96226727, or about 48.11 %.
%C Total count of those repeated 2 times is 45055158.
%C Total count of those repeated 3 times is 4554221, or about 2.28 %.
%C Total count of those repeated 4 times is 70 (extremely low).
%C Repeatedly applying this BitStoneA(v) function to values in a recursive (nested) style has shown that only 21 starting values shall become zero. These are those values: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, 23, 27. All other values shall cycle forever in small loops.
%C 274877906962 is the smallest number that occurs 5 times. - _Donovan Johnson_, Jul 27 2013
%H Andres M. Torres, <a href="/A227361/b227361.txt">Table of n, a(n) for n = 0..10000</a>
%F a(n) = n + (-1)^n sum_{j = 1 .. floor(log_2(n)) + 1} (floor(n/2^j + 1/2)) - floor(n/2^j)). - _Alonso del Arte_, Jul 08 2013, based on one of _Hieronymus Fischer_'s formulas for A000120.
%e a(0) = 0 because 0 is even, so 0 + bitsum(0) = 0.
%e a(1) = 0 because 1 is odd, so 1 - bitsum(1) = 0.
%e a(2) = 3 because 2 is even, so 2 + bitsum(2) = 3.
%e a(3) = 1 because 3 is odd, so 3 - bitsum(3) = 1.
%t Table[n + (-1)^n DigitCount[n, 2, 1], {n, 0, 127}] (* _Alonso del Arte_, Jul 08 2013 *)
%o (Blitz3D)
%o ;; Each a(n) is generated simply as follows: a(n) = BitStoneA(n)
%o Function BitStoneA(n)
%o If (n Mod 2) ;; if is odd
%o Return n-bitsum(n)
%o Else ;; if is even
%o Return n+bitsum(n)
%o End If
%o End Function
%o ;; --- Or, If n is even, then return n+A000120(n), else return n-A000120(n), where A000120(n) = bitsum(n)
%o (PARI) a(n)=n+(-1)^(n%2)*hammingweight(n) \\ _Charles R Greathouse IV_, Jul 09 2013
%Y Cf. A000120, A055938, A010061, A010062.
%K nonn,easy,base
%O 0,3
%A _Andres M. Torres_, Jul 08 2013