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.

Original entry on oeis.org

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

Views

Author

Christoph Schreier, Apr 13 2020

Keywords

Crossrefs

Programs

  • 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 *)
  • PARI
    a(n)=if(n, my(s=n^2); bitneg(s,exponent(s)+1), 1) \\ Charles R Greathouse IV, Apr 13 2020
    
  • 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)
    
  • Python
    def A334042(n):
        return 2**(len(bin(n**2))-2)-1-n**2 # Chai Wah Wu, Apr 13 2020

Formula

a(n) = A035327(A000290(n)). - Alois P. Heinz, Apr 13 2020