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.

Showing 1-7 of 7 results.

A145768 a(n) = the bitwise XOR of squares of first n natural numbers.

Original entry on oeis.org

0, 1, 5, 12, 28, 5, 33, 16, 80, 1, 101, 28, 140, 37, 225, 0, 256, 33, 357, 12, 412, 37, 449, 976, 400, 993, 325, 924, 140, 965, 65, 896, 1920, 961, 1861, 908, 1692, 965, 1633, 912, 1488, 833, 1445, 668, 1292, 741, 2721, 512, 2816, 609, 2981, 396, 2844, 485
Offset: 0

Views

Author

Vladimir Reshetnikov, Oct 18 2008

Keywords

Comments

Up to n=10^8, a(15) is the only zero term and a(1)=a(9) are the only terms for which a(n)=1. Can it be proved that any number can only appear a finite number of times in this sequence? [M. F. Hasler, Oct 20 2008]
Even terms occur at A014601, odd terms at A042963; A010873(a(n))=A021913(n+1). - Reinhard Zumkeller, Jun 05 2012
If squares occur, they must be at indexes != 2 or 5 (mod 8). - Roderick MacPhee, Jul 17 2017

Crossrefs

Programs

  • Haskell
    import Data.Bits (xor)
    a145768 n = a145768_list !! n
    a145768_list = scanl1 xor a000290_list  -- Reinhard Zumkeller, Jun 05 2012
    
  • Maple
    A[0]:= 0:
    for n from 1 to 100 do A[n]:= Bits:-Xor(A[n-1],n^2) od:
    seq(A[i],i=0..100); # Robert Israel, Dec 08 2019
  • Mathematica
    Rest@ FoldList[BitXor, 0, Array[#^2 &, 50]]
  • PARI
    an=0; for( i=1,50, print1(an=bitxor(an,i^2),",")) \\ M. F. Hasler, Oct 20 2008
    
  • PARI
    al(n)=local(m);vector(n,k,m=bitxor(m,k^2))
    
  • Python
    from functools import reduce
    from operator import xor
    def A145768(n):
        return reduce(xor, [x**2 for x in range(n+1)]) # Chai Wah Wu, Aug 08 2014

Formula

a(n)=1^2 xor 2^2 xor ... xor n^2.

A221643 Numbers k such that k^2 XOR (k+1)^2 is a square, where XOR is the bitwise XOR operator.

Original entry on oeis.org

0, 3, 4, 23, 24, 43, 44, 76, 111, 112, 115, 139, 164, 180, 183, 248, 264, 323, 327, 348, 411, 479, 480, 499, 611, 699, 747, 787, 943, 976, 1072, 1103, 1111, 1176, 1268, 1388, 1447, 1576, 1684, 1851, 1983, 1984, 2008, 2243, 2692, 3271, 3383, 3452, 3464, 3532, 3679, 3804, 3867
Offset: 1

Views

Author

Alex Ratushnyak, Mar 27 2013

Keywords

Crossrefs

Programs

  • Python
    import math
    for i in range(1<<16):
        s = (i*i) ^ ((i+1)*(i+1))
        t = int(math.sqrt(s))
        if s == t*t:
            print(str(i), end=',')

A145829 Square root of squares in A145768 (XOR of squares of the numbers 1..n).

Original entry on oeis.org

1, 4, 1, 15, 0, 16, 20, 31, 16, 49, 65, 224, 96, 96, 337, 144, 720, 400, 945, 625, 928, 828, 367, 928, 1889, 624, 2609, 3568, 3568, 2064, 10273, 1040, 545, 12384, 12639, 56800, 25812, 15119, 36, 864, 144383, 146463, 195440, 61391, 61072, 61072, 58128, 25872
Offset: 1

Views

Author

M. F. Hasler, Oct 20 2008

Keywords

Crossrefs

a(n) = A000196( A145828(n)) = A000196( A145768( A145827(n))); A145828 = { a(n)^2 } = A145768 intersect A000290.

Programs

  • Haskell
    a145829 n = a145829_list !! (n-1)
    a145829_list = map a000196 $ filter ((== 1) . a010052) $ tail a145768_list
    -- Reinhard Zumkeller, Nov 09 2012
    
  • Mathematica
    an = 0; Reap[ For[i = 1, i <= 10^6, i++, an = BitXor[an, i^2]; If[IntegerQ[r = Sqrt[an]], Print[r]; Sow[r]]]][[2, 1]] (* Jean-François Alcover, Oct 11 2013, translated from Pari *)
  • PARI
    an=0; for( i=1,10^4, an=bitxor(an,i^2); issquare(an,&an) && print1(an","))
    
  • Python
    from itertools import count, islice
    from sympy import integer_nthroot
    def A145829gen(): # generator of terms
        m = 0
        for n in count(1):
            m ^= n**2
            a, b = integer_nthroot(m,2)
            if b: yield a
    A145829_list = list(islice(A145829gen(),20)) # Chai Wah Wu, Dec 16 2021

A145828 Squares in A145768 (XOR of squares of the numbers 1...n).

Original entry on oeis.org

0, 1, 16, 1, 225, 0, 256, 400, 961, 256, 2401, 4225, 50176, 9216, 9216, 113569, 20736, 518400, 160000, 893025, 390625, 861184, 685584, 134689, 861184, 3568321, 389376, 6806881, 12730624, 12730624, 4260096, 105534529
Offset: 1

Views

Author

M. F. Hasler, Oct 20 2008

Keywords

Crossrefs

Equals A145768 intersect A000290; a(n) = A145768(A145827(n)) = A145829(n)^2.

Programs

  • Mathematica
    Reap[For[Sow[x=0]; k=1, k <= 10^4, k++, x = BitXor[x, k^2]; If[IntegerQ[ Sqrt[x]], Sow[x]]]][[2, 1]] (* Jean-François Alcover, Nov 25 2015 *)
  • PARI
    an=0; for( i=1,10^4, an=bitxor(an,i^2); issquare(an) && print1(an","))
    
  • PARI
    {a(n) = my(x, m, k); while( mMichael Somos, Aug 05 2014 */
  • Python
    from gmpy2 import is_square
    filter(is_square, [reduce(lambda x,y:x^y, [x**2 for x in range(n)]) for n in range(1,10**4)]) # Chai Wah Wu, Aug 05 2014
    

Extensions

Edited to start at 0 to match A145768 by Chai Wah Wu, Aug 05 2014

A145830 Indices for which A145768 (XOR of squares of the numbers 1...n) is a power of 2.

Original entry on oeis.org

1, 7, 9, 16, 47, 63
Offset: 1

Views

Author

M. F. Hasler, Oct 20 2008

Keywords

Comments

Next term is > 10^7.
a(7) > 1.5*10^9. [Jon E. Schoenfield, Jan 14 2009]
a(7) > 10^11. [Sean A. Irvine, Aug 12 2010]

Crossrefs

A145830 = A145768 intersect A000079. A145768(a(n)) = 2^A145831(n); See also A145827-A145829.

Programs

  • Mathematica
    Position[ FoldList[ BitXor, 0, Range[10^6]^2], n_ /; IntegerQ[Log[2, n]]] - 1 // Flatten (* Jean-François Alcover, Sep 30 2013 *)
  • PARI
    an=0; for( i=1,10^6, an=bitxor(an,i^2); an & an==1<
    				

A145831 Log_2 ( A145768( A145830(n))).

Original entry on oeis.org

0, 4, 0, 8, 9, 8
Offset: 1

Views

Author

M. F. Hasler, Oct 20 2008

Keywords

Crossrefs

A145830 = A145768 intersect A000079. A145768(A145830(n)) = 2^a(n). See also A145827-A145829.

Programs

  • PARI
    an=0; for( i=1,10^7, an=bitxor(an,i^2); an & an==1<
    				

A220518 Numbers n such that A193232(n) is a triangular number.

Original entry on oeis.org

0, 1, 5, 9, 45, 49, 101, 153, 1569, 7163, 7171, 8162, 18974, 18976, 24467, 33490, 60290, 63046, 359539, 551494, 1769418, 2813691, 4140392, 4649729, 6675935, 9653486, 59131393, 158169499, 243345386, 588183781, 1315697727, 1387290631, 1522472645, 1879098546
Offset: 1

Views

Author

Alex Ratushnyak, Mar 27 2013

Keywords

Comments

Numbers k such that bitwise XOR of first k triangular numbers is a triangular number.

Crossrefs

Cf. A193232.
Cf. A145827 (bitwise XOR of first k squares is a square).

Programs

  • C
    #include 
    typedef unsigned long long U64;
    U64 rootTriangular(U64 a) {
        U64 sr = 1L<<32, s, b;
        if (a < (sr/2)*(sr+1)) {
          sr>>=1;
          while (a < sr*(sr+1)/2)  sr>>=1;
        }
        for (b = sr>>1; b; b>>=1) {
            s = sr+b;
            if (a >= s*(s+1)/2)  sr = s;
        }
        return sr;
    }
    int main() {
      U64 a=0, i, t;
      for (i=0; i < 1L<<32; ++i) {
          a ^= i*(i+1)/2;
          t = rootTriangular(a);
          if (a == t*(t+1)/2)  printf("%llu\n", i);
      }
      return 0;
    }
Showing 1-7 of 7 results.