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-5 of 5 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.

A003816 a(0) = 0, a(n) = a(n-1) XOR -n.

Original entry on oeis.org

0, 1, -1, 4, 0, 5, -1, 8, 0, 9, -1, 12, 0, 13, -1, 16, 0, 17, -1, 20, 0, 21, -1, 24, 0, 25, -1, 28, 0, 29, -1, 32, 0, 33, -1, 36, 0, 37, -1, 40, 0, 41, -1, 44, 0, 45, -1, 48, 0, 49, -1, 52, 0, 53, -1, 56, 0, 57, -1, 60, 0, 61, -1, 64, 0, 65, -1, 68
Offset: 0

Views

Author

Keywords

Crossrefs

Cf. A003815.

Programs

  • Magma
    [(n-(n+1)*(-1)^n+(-1)^((2*n+1-(-1)^n) div 4))/2 : n in [0..100]]; // Wesley Ivan Hurt, May 03 2016
  • Maple
    A003816:=n->(n-(n+1)*(-1)^n+(-1)^((2*n+1-(-1)^n)/4))/2: seq(A003816(n), n=0..150); # Wesley Ivan Hurt, May 03 2016
  • Mathematica
    CoefficientList[Series[x*(1 - x + 3 x^2 + x^3)/((x^2 - 1)^2*(x^2 + 1)), {x, 0, 100}], x] (* Wesley Ivan Hurt, May 01 2016 *)
    nxt[{n_,a_}]:={n+1,BitXor[a,-n-1]}; -#&/@(NestList[nxt,{0,0},70][[All,2]]) (* or *) LinearRecurrence[{0,1,0,1,0,-1},{0,1,-1,4,0,5},70] (* Harvey P. Dale, Oct 16 2019 *)
  • PARI
    a(n)=([0,1,0,0,0,0; 0,0,1,0,0,0; 0,0,0,1,0,0; 0,0,0,0,1,0; 0,0,0,0,0,1; -1,0,1,0,1,0]^n*[0;1;-1;4;0;5])[1,1] \\ Charles R Greathouse IV, May 02 2016
    

Formula

G.f.: x*(1-x+3x^2+x^3)/((x^2-1)^2*(x^2+1)).
|a(n)| = n-(-1)^n*|a(n-1)|. - Vladeta Jovovic, Mar 13 2003
a(4n)=0, a(4n+1)=4n+1, a(4n+2)=-1, a(4n+3)=4n+4, n>=0.
From Wesley Ivan Hurt, May 01 2016, May 03 2016: (Start)
a(n) = a(n-2)+a(n-4)-a(n-6) for n>5.
a(n) = (-1)^floor((n-1)/2) * Sum_{i=0..n} i*(-1)^floor(i/2).
a(n) = (n-(n+1)*(-1)^n+(-1)^((2*n+1-(-1)^n)/4))/2. (End)
E.g.f.: (cos(x) + (-1 + 2*x)*cosh(x) - sin(x) + sinh(x))/2. - Ilya Gutkovskiy, May 03 2016

A126084 a(n) = XOR of first n primes.

Original entry on oeis.org

0, 2, 1, 4, 3, 8, 5, 20, 7, 16, 13, 18, 55, 30, 53, 26, 47, 20, 41, 106, 45, 100, 43, 120, 33, 64, 37, 66, 41, 68, 53, 74, 201, 64, 203, 94, 201, 84, 247, 80, 253, 78, 251, 68, 133, 64, 135, 84, 139, 104, 141, 100, 139, 122, 129, 384, 135, 394, 133, 400, 137, 402, 183, 388, 179
Offset: 0

Views

Author

Esko Ranta, Mar 02 2007

Keywords

Comments

The values at odd positive indices are even and the values at even positive indices are odd.
Does this sequence contain any zeros for n > 0? Probabilistically, one would expect so; but none in first 10000 terms. - Franklin T. Adams-Watters, Jul 17 2011
None below 1.5 * 10^11: any prime p such that a(pi(p)) = 0 is 43 bits or longer. Heuristic chances that a prime below 2^100 yields 0 are about 45%. Note that an n-bit prime can yield 0 only if a(pi(p)) is odd, where p is the smallest n-bit prime. That is, for n > 1, there are no zeros from pi(2^n) to pi(2^(n+1)) if A007053(n) is even. - Charles R Greathouse IV, Jul 17 2011

Examples

			a(4) = 3 because ((2 XOR 3) XOR 5) XOR 7 = (1 XOR 5) XOR 7 = 4 XOR 7 = 3
[Or, in base 2]
((10 XOR 11) XOR 101) XOR 111 = (1 XOR 101) XOR 111 = 100 XOR 111 = 11
		

Crossrefs

Programs

  • Mathematica
    Module[{nn=70,prs},prs=Prime[Range[nn]];Table[BitXor@@Take[prs,n],{n,0,nn}]] (* Harvey P. Dale, Jun 23 2016 *)
  • PARI
    al(n)=local(m);vector(n,k,m=bitxor(m,prime(k))) /* Produces a vector without a(0) = 0; Franklin T. Adams-Watters, Jul 17 2011 */
    
  • PARI
    v=primes(300); for(i=2,#v,v[i]=bitxor(v[i],v[i-1])); concat(0, v) \\ Charles R Greathouse IV, Aug 26 2014
    
  • PARI
    q=0; forprime(p=2, 313, print1(q, ","); q=bitxor(q, p)) /* Klaus Brockhaus, Mar 06 2007; adapted by Rémy Sigrist, Oct 23 2017 */
    
  • Python
    from operator import xor
    from functools import reduce
    from sympy import primerange, prime
    def A126084(n): return reduce(xor,primerange(2,prime(n)+1)) if n else 0 # Chai Wah Wu, Jul 09 2022

Formula

a(0) = 0; a(n) = a(n-1) XOR prime(n).

Extensions

More terms from Klaus Brockhaus, Mar 06 2007
Edited by N. J. A. Sloane, Oct 22 2017 (merging old entry A193174 with this)
Edited by Rémy Sigrist, Oct 23 2017

A077140 a(1) = 1 and then add n to the previous term if n is coprime to the previous term, otherwise subtract n from the previous term. a(1) = 1 and a(n) = a(n-1) + n if gcd(n, a(n-1)) = 1, otherwise a(n) = a(n-1) - n.

Original entry on oeis.org

1, 3, 0, -4, 1, 7, 0, -8, 1, 11, 0, -12, 1, 15, 0, -16, 1, 19, 0, -20, 1, 23, 0, -24, 1, 27, 0, -28, 1, 31, 0, -32, 1, 35, 0, -36, 1, 39, 0, -40, 1, 43, 0, -44, 1, 47, 0, -48, 1, 51, 0, -52, 1, 55, 0
Offset: 1

Views

Author

Amarnath Murthy, Oct 30 2002

Keywords

Comments

a(2k+1) = (k+1) (mod 2), a(4k) = -4k, a(4k+2) = 4k+3. Proof: If a(4k+3)=0 then a(4k+4) = -4k-4, a(4k+5)=1, a(4k+6) = 1+4k+6 and again, a(4k+7)=0. - Ralf Stephan, Mar 18 2003
Abs(a(n)) = A003815(n). - Reinhard Zumkeller, Oct 09 2007
With different signs, it can be obtained as abs(a(n)) = abs(Sum_{i=0..n} (-1)^h(i)*i) where h(i) is the Hamming weight of i, A000120, the number of 1s in base 2. - Olivier Gérard, Jul 30 2012

Examples

			From _Ilya Gutkovskiy_, Dec 21 2015: (Start)
a(1) = 1;
a(2) = 1 + 2 = 3;
a(3) = 1 + 2 - 3 = 0;
a(4) = 1 + 2 - 3 - 4 = -4;
a(5) = 1 + 2 - 3 - 4 + 5 = 1;
a(6) = 1 + 2 - 3 - 4 + 5 + 6 = 7;
a(7) = 1 + 2 - 3 - 4 + 5 + 6 - 7 = 0;
a(8) = 1 + 2 - 3 - 4 + 5 + 6 - 7 - 8 = -8; etc. (End)
		

Crossrefs

Cf. A077141.

Programs

  • Mathematica
    CoefficientList[Series[(x^2-2x-1)/((x^2+1)^2*(x-1)),{x,0,100}],x] (* Vincenzo Librandi, Jul 30 2012 *)
    nxt[{n_,a_}]:={n+1,If[CoprimeQ[a,n+1],a+n+1,a-n-1]}; NestList[nxt,{1,1},60][[All,2]] (* Harvey P. Dale, Jul 26 2020 *)
  • PARI
    v=vector(100);v[1]=1;for(k=2,100,if(gcd(v[k-1],k)>1,v[k]=v[k-1]-k,v[k]=v[k-1]+k));print(v)

Formula

a(1) = 1 and a(n) = a(n-1) + n if gcd(n, a(n-1)) = 1, otherwise a(n) = a(n-1) - n.
G.f.: x(x^2-2x-1)/((x^2+1)^2*(x-1)). - Ralf Stephan, Mar 18 2003
Abs(a(n)) = ((n+1) mod 2)*n + (floor((n+(n mod 2))/2) mod 2). - Tj Wrenn (tjwrenn(AT)cs.utexas.edu), Apr 07 2005
a(n) = Sum_{k = 1..n} (-(-1)^((2*k - (-1)^k + 1)/4)*k). - Ilya Gutkovskiy, Dec 21 2015

Extensions

More terms from Ralf Stephan, Mar 18 2003

A193232 Bitwise XOR of first n triangular numbers.

Original entry on oeis.org

0, 1, 2, 4, 14, 1, 20, 8, 44, 1, 54, 116, 58, 97, 8, 112, 248, 97, 202, 116, 166, 65, 188, 424, 132, 449, 158, 484, 114, 449, 16, 480, 1008, 449, 914, 484, 894, 449, 804, 40, 796, 65, 966, 116, 938, 1953, 920, 2032, 872, 1953, 858, 1652, 790, 1665, 844, 1352
Offset: 0

Views

Author

Keywords

Crossrefs

Programs

  • Maple
    a:= proc(n) option remember; `if`(n=0, 0,
          Bits[Xor](a(n-1), n*(n+1)/2))
        end:
    seq(a(n), n=0..55);  # Alois P. Heinz, Feb 19 2023
  • Mathematica
    Module[{nn=60,trs},trs=Accumulate[Range[nn]];Table[BitXor@@Take[trs,n],{n,0,nn}]] (* Harvey P. Dale, Dec 15 2017 *)
  • PARI
    al(n) = local(m); vector(n,k,m=bitxor(m,k*(k+1)\2))
    
  • Python
    from operator import xor
    from functools import reduce
    def A193232(n): return reduce(xor, (x*(x+1) for x in range(n+1)))//2 # Chai Wah Wu, Dec 16 2021
Showing 1-5 of 5 results.