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.

A298816 a(n) is the binary XOR of all n-bit squares, with a(2)=0 indicating that no 2-bit squares exist.

Original entry on oeis.org

1, 0, 4, 9, 9, 21, 12, 28, 449, 577, 357, 997, 6085, 14533, 12517, 15077, 121125, 152869, 400028, 1041052, 1290704, 2556368, 4913664, 11950592, 22421376, 63692672, 7674753, 78355329, 312723717, 656197893, 1089399836, 2723474460, 4196236289, 2416016385, 8186515468
Offset: 1

Views

Author

Alex Ratushnyak, Jan 26 2018

Keywords

Comments

XOR is the binary exclusive-or operator.

Examples

			There are two squares whose binary representation is 5 bits long, namely 16 and 25. a(5) = 9 because 25 XOR 16 = 9.
There are four squares whose binary representation is 7 bits long, namely 64, 81, 100 and 121. a(7) = (64 XOR 81 XOR 100 XOR 121) = 12.
		

Crossrefs

Programs

  • Python
    i = n = x = L = 1
    while L < 47:
        i+=1
        nextn = i*i
        if (nextn ^ n) > n:  # if lengths of binary representations are different
            print(x, end=', ')
            x = 0
            prevL = L
            L = len(bin(nextn))-2
            for j in range(prevL, L-1):  print(0, end=', ')
        n = nextn
        x ^= n