%I #24 Apr 13 2020 18:19:25
%S 1,0,3,6,15,6,27,14,63,46,27,6,111,86,59,30,255,222,187,150,111,70,27,
%T 494,447,398,347,294,239,182,123,62,1023,958,891,822,751,678,603,526,
%U 447,366,283,198,111,22,1979,1886,1791,1694,1595,1494,1391,1286,1179
%N Write n^2 in binary, interchange 0's and 1's, convert back to decimal.
%H Daniel Starodubtsev, <a href="/A334042/b334042.txt">Table of n, a(n) for n = 0..10000</a>
%F a(n) = A035327(A000290(n)). - _Alois P. Heinz_, Apr 13 2020
%p a:= n-> (l-> add((1-l[i])*2^(i-1), i=1..nops(l)))(convert(n, base, 2)):
%p seq(a(n), n=0..60); # _Alois P. Heinz_, Apr 13 2020
%t a[n_] := FromDigits[1 - IntegerDigits[n^2, 2], 2]; Array[a, 55, 0] (* _Amiram Eldar_, Apr 13 2020 *)
%o (Python)
%o def oppsquare(n):
%o s = str(bin(n**2))[2:]
%o t = ''
%o for i in range(len(s)):
%o if s[i] == '0':
%o t += '1'
%o else:
%o t += '0'
%o return int(t,2)
%o (PARI) a(n)=if(n, my(s=n^2); bitneg(s,exponent(s)+1), 1) \\ _Charles R Greathouse IV_, Apr 13 2020
%o (Python)
%o def A334042(n):
%o return 2**(len(bin(n**2))-2)-1-n**2 # _Chai Wah Wu_, Apr 13 2020
%Y Cf. A000290, A035327.
%K nonn,base,easy
%O 0,3
%A _Christoph Schreier_, Apr 13 2020
|