login
A334042
Write n^2 in binary, interchange 0's and 1's, convert back to decimal.
1
1, 0, 3, 6, 15, 6, 27, 14, 63, 46, 27, 6, 111, 86, 59, 30, 255, 222, 187, 150, 111, 70, 27, 494, 447, 398, 347, 294, 239, 182, 123, 62, 1023, 958, 891, 822, 751, 678, 603, 526, 447, 366, 283, 198, 111, 22, 1979, 1886, 1791, 1694, 1595, 1494, 1391, 1286, 1179
OFFSET
0,3
LINKS
FORMULA
a(n) = A035327(A000290(n)). - Alois P. Heinz, Apr 13 2020
MAPLE
a:= n-> (l-> add((1-l[i])*2^(i-1), i=1..nops(l)))(convert(n, base, 2)):
seq(a(n), n=0..60); # Alois P. Heinz, Apr 13 2020
MATHEMATICA
a[n_] := FromDigits[1 - IntegerDigits[n^2, 2], 2]; Array[a, 55, 0] (* Amiram Eldar, Apr 13 2020 *)
PROG
(Python)
def oppsquare(n):
s = str(bin(n**2))[2:]
t = ''
for i in range(len(s)):
if s[i] == '0':
t += '1'
else:
t += '0'
return int(t, 2)
(PARI) a(n)=if(n, my(s=n^2); bitneg(s, exponent(s)+1), 1) \\ Charles R Greathouse IV, Apr 13 2020
(Python)
def A334042(n):
return 2**(len(bin(n**2))-2)-1-n**2 # Chai Wah Wu, Apr 13 2020
CROSSREFS
Sequence in context: A058141 A144654 A132279 * A066107 A162276 A261955
KEYWORD
nonn,base,easy
AUTHOR
Christoph Schreier, Apr 13 2020
STATUS
approved