cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A334042 Write n^2 in binary, interchange 0's and 1's, convert back to decimal.

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