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-10 of 43 results. Next

A345927 Alternating sum of the binary expansion of n (row n of A030190). Replace 2^k with (-1)^(A070939(n)-k) in the binary expansion of n (compare to the definition of A065359).

Original entry on oeis.org

0, 1, 1, 0, 1, 2, 0, 1, 1, 0, 2, 1, 0, -1, 1, 0, 1, 2, 0, 1, 2, 3, 1, 2, 0, 1, -1, 0, 1, 2, 0, 1, 1, 0, 2, 1, 0, -1, 1, 0, 2, 1, 3, 2, 1, 0, 2, 1, 0, -1, 1, 0, -1, -2, 0, -1, 1, 0, 2, 1, 0, -1, 1, 0, 1, 2, 0, 1, 2, 3, 1, 2, 0, 1, -1, 0, 1, 2, 0, 1, 2, 3, 1, 2
Offset: 0

Views

Author

Gus Wiseman, Jul 14 2021

Keywords

Comments

The alternating sum of a sequence (y_1,...,y_k) is Sum_i (-1)^(i-1) y_i.

Examples

			The binary expansion of 53 is (1,1,0,1,0,1), so a(53) = 1 - 1 + 0 - 1 + 0 - 1 = -2.
		

Crossrefs

Binary expansions of each nonnegative integer are the rows of A030190.
The positions of 0's are A039004.
The version for prime factors is A071321 (reverse: A071322).
Positions of first appearances are A086893.
The version for standard compositions is A124754 (reverse: A344618).
The version for prime multiplicities is A316523.
The version for prime indices is A316524 (reverse: A344616).
A003714 lists numbers with no successive binary indices.
A070939 gives the length of an integer's binary expansion.
A103919 counts partitions by sum and alternating sum.
A328594 lists numbers whose binary expansion is aperiodic.
A328595 lists numbers whose reversed binary expansion is a necklace.

Programs

  • Mathematica
    ats[y_]:=Sum[(-1)^(i-1)*y[[i]],{i,Length[y]}];
    Table[ats[IntegerDigits[n,2]],{n,0,100}]
  • PARI
    a(n) = subst(Pol(Vecrev(binary(n))), x, -1); \\ Michel Marcus, Jul 19 2021
    
  • Python
    def a(n): return sum((-1)**k for k, bi in enumerate(bin(n)[2:]) if bi=='1')
    print([a(n) for n in range(84)]) # Michael S. Branicky, Jul 19 2021

Formula

a(n) = (-1)^(A070939(n)-1)*A065359(n).

A065084 Smallest prime having alternating bit sum (A065359) equal to n.

Original entry on oeis.org

3, 7, 5, 0, 277, 1109, 0, 17749, 70997, 0, 1398037, 5526869, 0, 72701269, 357915989, 0, 5659514197, 22902297941, 0, 297784399189, 1465948394837, 0, 23456248042837, 89426945725781, 0, 1430831131612501, 6004798429418837, 0
Offset: 0

Views

Author

Robert G. Wilson v, Nov 09 2001

Keywords

Comments

Only 3d = 11b has an alternating sum of 0 and alternated sums of 3*k are impossible for primes.

Examples

			a(4)=277 since the smallest number having alternating bit sum n is (4^n-1)/3, which for n = 4 is 85. Because 85 =(1010101)2 is composite, the next number with alternating bit sum 4 is the prime (100010101)2 = 277. - _Washington Bomfim_, Jan 21 2011
		

Crossrefs

Programs

  • Mathematica
    f[n_] := (d = Reverse[ IntegerDigits[n, 2]]; l = Length[d]; s = 0; k = 1; While[k < l + 1, s = s - (-1)^k*d[[k]]; k++ ]; s); a = Table[ f[ Prime[n]], {n, 1, 10^6} ]; b = Table[0, {13} ];
    Do[ If[ a[[n]] > -1 && b[[a[[n]] + 1]] == 0, b[[a[[n]] + 1]] = Prime[n]], {n, 1, 10^6} ]; b
  • PARI
    M(n)={return((4^n - 1)/3 + 2^(2*n) - 2^(2*n-2))};
    T(n,k)={pow2=2^(2*n-2);k+=pow2; for(j=1,n-2,pow2/=4; k-=pow2;if(isprime(k),return(k),k+=pow2;)); return(k)};
    T2(n,k)={pow2=2; for(j=1,n, k+=pow2;if(isprime(k),return(k),k-=pow2; pow2*=4)); return(k)};
    print("0 3");print("1 7");print("2 5");print("3 0");for(n=4,127,if(n%3==0,print(n," 0"),k=M(n);if(isprime(k),print(n," ",k),k=T(n,k);if(isprime(k),print(n," ",k),k=T2(n,k);if(isprime(k),print(n," ",k),print("a(",n,") not found")))))) \\ Washington Bomfim, Jan 22 2011

Extensions

a(14)-a(27) from Washington Bomfim, Jan 21 2011

A065085 Smallest prime having alternating bit sum (A065359) equal to -n, or 0 if no such prime exists.

Original entry on oeis.org

3, 2, 43, 0, 683, 2731, 0, 43691, 174763, 0, 2796203, 44608171, 0, 715827881, 715827883, 0, 114532461227, 183251938027, 0, 2931494136491, 2932031007403, 0, 187647836990123, 748400914639531, 0, 11446649052900011, 45786596211600043, 0
Offset: 0

Views

Author

Robert G. Wilson v, Nov 09 2001

Keywords

Examples

			The smallest number having alternating bit sum -n is (2/3)(4^n-1), which for n=4 is 170 = (10101010)2. The least odd number with alternating bit sum -4 is (10)2 || ( (10101010)2 + (1)2 ) = 683, which is prime, so a(4) = 683. - _Washington Bomfim_, Jan 27 2011
		

Crossrefs

Programs

  • Mathematica
    f[n_] := Plus @@ (-(-1)^Range[Floor[Log2@n + 1]] Reverse@ IntegerDigits[n, 2]); a = Table[ f[ Prime[n]], {n, 1, 10^6} ]; b = Table[0, {12} ]; Do[ If[ a[[n]] < 1 && b[[ -a[[n]] + 1]] == 0, b[[ -a[[n]] + 1]] = Prime[n]], {n, 1, 10^6} ]; b
  • PARI
    II()={i = (2/3)*(4^n-1) + 1 + 2^(2*n+1); if(isprime(i),return(1)); return(0)};
    III()={w = 2^(2*n+3); for(j=1, n+1, i += w; w /= 4; i -= w; if(isprime(i),return(1))); return(0)};
    IV()={i+=6; if(isprime(i), return(1)); w=4; for(j=1, n, i -= w; w*=4; i+=w; if(isprime(i), return(1)));return(0)};
    V()={i += 2^(2*n+4) - 2^(2*n+2); if(isprime(i),return(1));w = i + 2^(2*n+5) - 2^(2*n+4); i = w - 2^(2*n+3) - 2^(2*n+1); if(isprime(i),return(1));w = 2^(2*n+1);for(j=1, n,i += w; w /= 4; i -= w;if(isprime(i),return(1) ));return(0)};
    print("0 3");print("1 2");for(n=2,117, if(II(),print(n," ",i), if(III(),print(n," ",i), if(IV(),print(n," ",i), if(V(),print(n," ",i),if(n%3==0,print(n," 0"),print(n," not found."))))))) \\ Washington Bomfim, Feb 06 2011

Extensions

a(13)-a(27) from Washington Bomfim, Jan 27 2011

A332204 a(n) is the real part of f(n) defined by f(0) = 0, and f(n+1) = f(n) + g((1+i)^(A065359(n) mod 8)) (where g(z) = z/gcd(Re(z), Im(z)) and i denotes the imaginary unit).

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 5, 6, 7, 8, 9, 9, 10, 11, 12, 13, 14, 15, 15, 16, 17, 17, 16, 17, 17, 18, 19, 20, 21, 22, 22, 23, 24, 25, 26, 26, 27, 28, 29, 30, 31, 31, 32, 31, 31, 32, 33, 33, 34, 35, 36, 37, 38, 39, 39, 40, 41, 42, 43, 43, 44, 45, 46, 47, 48, 49, 49, 50
Offset: 0

Views

Author

Rémy Sigrist, Feb 07 2020

Keywords

Comments

The representation of {f(n)} resembles a Koch curve (see illustrations in Links section).
The sequence A065359 mod 8 gives the direction at each step as follows:
3 2 1
\ | /
\ | /
\|/
4 ------.------ 0
5 6 7
We can also build {f(n)} with A096268 as follows:
- start at the origin looking to the right,
- for k=0, 1, ...:
- move forward to the next lattice point
(this point is at distance 1 or sqrt(2)),
- if A096268(k)=0
then turn 45 degrees to the left
otherwise turn 90 degrees to the right,
- this connects the first differences of A065359 and A096268.

Examples

			The first terms, alongside f(n) and A065359(n), are:
  n   a(n)  f(n)   A065359(n)
  --  ----  -----  ----------
   0     0      0           0
   1     1      1           1
   2     2    2+i          -1
   3     3      3           0
   4     4      4           1
   5     5    5+i           2
   6     5  5+2*i           0
   7     6  6+2*i           1
   8     7  7+3*i          -1
   9     8  8+2*i           0
  10     9  9+2*i          -2
  11     9    9+i          -1
  12    10     10           0
  13    11     11           1
  14    12   12+i          -1
  15    13     13           0
  16    14     14           1
		

Crossrefs

Cf. A065359, A096268, A217730, A332205 (imaginary part), A332206 (where f is real).

Programs

  • Mathematica
    A065359[0] = 0;
    A065359[n_] := -Total[(-1)^PositionIndex[Reverse[IntegerDigits[n, 2]]][1]];
    g[z_] := z/GCD[Re[z], Im[z]];
    Module[{n = 0}, Re[NestList[# + g[(1+I)^A065359[n++]] &, 0, 100]]] (* Paolo Xausa, Aug 28 2024 *)
  • PARI
    \\ See Links section.

Formula

a(2^k) = A217730(k) for any k >= 0.
a(4^k+m) + a(m) = A217730(2*k) for any k >= 0 and m = 0..4^k.

A332205 a(n) is the imaginary part of f(n) defined by f(0) = 0, and f(n+1) = f(n) + g((1+i)^(A065359(n) mod 8)) (where g(z) = z/gcd(Re(z), Im(z)) and i denotes the imaginary unit).

Original entry on oeis.org

0, 0, 1, 0, 0, 1, 2, 2, 3, 2, 2, 1, 0, 0, 1, 0, 0, 1, 2, 2, 3, 4, 5, 6, 7, 7, 8, 7, 7, 8, 9, 9, 10, 9, 9, 8, 7, 7, 8, 7, 7, 6, 5, 4, 3, 2, 2, 1, 0, 0, 1, 0, 0, 1, 2, 2, 3, 2, 2, 1, 0, 0, 1, 0, 0, 1, 2, 2, 3, 4, 5, 6, 7, 7, 8, 7, 7, 8, 9, 9, 10, 11, 12, 13, 14
Offset: 0

Views

Author

Rémy Sigrist, Feb 07 2020

Keywords

Comments

Looks much like A005536, in particular in respect of its symmetries of scale (compare the scatterplots). - Peter Munn, Jun 21 2021

Crossrefs

Cf. A005536, A007052, A065359, A332204 (real part and additional comments), A332206 (positions of 0's, cf. A001196).

Programs

  • Mathematica
    A065359[0] = 0;
    A065359[n_] := -Total[(-1)^PositionIndex[Reverse[IntegerDigits[n, 2]]][1]];
    g[z_] := z/GCD[Re[z], Im[z]];
    Module[{n = 0}, Im[NestList[# + g[(1+I)^A065359[n++]] &, 0, 100]]] (* Paolo Xausa, Aug 28 2024 *)
  • PARI
    \\ See Links section.

Formula

a(2^(2*k-1)) = A007052(k) for any k >= 0.
a(4^k-m) = a(m) for any k >= 0 and m = 0..4^k.

A065081 Alternating bit sum (A065359) for n-th prime p: replace 2^k with (-1)^k in binary expansion of p.

Original entry on oeis.org

-1, 0, 2, 1, -1, 1, 2, 1, 2, 2, 1, 1, -1, -2, -1, 2, -1, 1, 1, 2, 1, 1, 2, 2, 1, 2, 1, -1, 1, 2, 1, -1, -1, -2, 2, 1, 1, -2, -1, -1, -1, 1, -1, 1, 2, 1, 1, 1, -1, 1, -1, -1, 1, -1, 2, 2, 2, 1, 4, 2, 1, 2, 1, 2, 1, 2, 1, 4, 2, 4, 2, 2, 1, 4, 1, 2, 2, 1, 2, 1, -1, 1, -1, 1, 1, -1, 2, 1, 2, 1, 2, 2, 1, -1, 1, 2, 2, -1, -2, 1
Offset: 1

Views

Author

Robert G. Wilson v, Nov 09 2001

Keywords

Comments

Only 3d = 11b has an alternating sum of 0.

Examples

			The sixth prime is 13d = 1101b -> -(1)+(1)-(0)+(1) = 1 = a(6)
		

Crossrefs

Cf. A065359.

Programs

  • Mathematica
    f[n_] := (d = Reverse[ IntegerDigits[n, 2]]; l = Length[d]; s = 0; k = 1; While[k < l + 1, s = s - (-1)^k*d[[k]]; k++ ]; s); Table[ Prime[ f[n]], {n, 1, 100} ]
  • PARI
    baseE(x, b)=
    {
      local(d, e=0, f=1);
      while (x>0, d=x-b*(x\b); x\=b; e+=d*f; f*=10);
      return(e)
    }
    SumAD(x)=
    {
      local(a=1, s=0);
      while (x>9, s+=a*(x-10*(x\10)); x\=10; a=-a);
      return(s + a*x)
    }
    { for (n=1, 1000, p=prime(n);
      s=SumAD(baseE(p, 2)); write("b065081.txt", n, " ", s) )
    } \\ Harry J. Smith, Oct 06 2009
    
  • PARI
    f(p)=
    {
      v=binary(p);
      L=#v; u=1; s=0;
      forstep(k=L,1,-1, if(v[k]==1,s+=u); u=-u;);
      return(s)
    };
    for(n=1,100,p=prime(n); an=f(p);print1(an,", ")) \\ Washington Bomfim, Jan 16 2011
    
  • Python
    from sympy.ntheory import digits, prime
    def A065081(n): return sum((0,1,-1,0)[i] for i in digits(prime(n),4)[1:]) # Chai Wah Wu, Jul 19 2024

A302544 Lexicographically earliest sequence of distinct nonnegative numbers such that for any n >= 0, A065359(a(n)) = - A065359(n).

Original entry on oeis.org

0, 2, 1, 3, 8, 10, 6, 11, 4, 9, 5, 7, 12, 14, 13, 15, 26, 34, 18, 32, 40, 42, 35, 43, 24, 38, 16, 27, 41, 46, 30, 44, 19, 33, 17, 22, 36, 47, 25, 39, 20, 28, 21, 23, 31, 45, 29, 37, 48, 50, 49, 51, 56, 58, 54, 59, 52, 57, 53, 55, 60, 62, 61, 63, 74, 106, 66
Offset: 0

Views

Author

Rémy Sigrist, Apr 09 2018

Keywords

Comments

This sequence is a self-inverse permutation of the nonnegative numbers, with fixed points A039004.
We can build an analog of this sequence for any base b > 1 by considering the alternating sum of digits in base b instead of A065359.
This sequence has similarities with A298847.
The scatter plots have an interesting, "fibrous" look. - Antti Karttunen, Jul 21 2018

Examples

			The first terms, alongside the binary representations of n and of a(n), and A065359(n), are:
  n   a(n)  bin(n)  bin(a(n))  A065359(n)
  --  ----  ------  ---------  ----------
   0     0       0       0      0
   1     2       1      10      1
   2     1      10       1     -1
   3     3      11      11      0
   4     8     100    1000      1
   5    10     101    1010      2
   6     6     110     110      0
   7    11     111    1011      1
   8     4    1000     100     -1
   9     9    1001    1001      0
  10     5    1010     101     -2
  11     7    1011     111     -1
  12    12    1100    1100      0
  13    14    1101    1110      1
  14    13    1110    1101     -1
  15    15    1111    1111      0
  16    26   10000   11010      1
  17    34   10001  100010      2
  18    18   10010   10010      0
  19    32   10011  100000      1
  20    40   10100  101000      2
		

Crossrefs

Cf. A039004 (fixed points), A065359, A298847.

A302840 Lexicographically earliest sequence of distinct positive terms such that any n > 0, A065359(a(n)) <= A065368(a(n+1)).

Original entry on oeis.org

1, 2, 3, 4, 5, 10, 6, 8, 7, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 21, 23, 26, 24, 25, 29, 38, 27, 28, 37, 41, 31, 45, 32, 35, 36, 40, 30, 44, 39, 46, 34, 42, 33, 47, 43, 48, 49, 50, 51, 52, 53, 74, 55, 65, 82, 73, 77, 83, 86, 90, 56, 59, 63, 64, 81
Offset: 1

Views

Author

Rémy Sigrist, Apr 14 2018

Keywords

Comments

See A302839 for a sequence with digital sums instead of alternate digital sums.

Examples

			The first terms, alongside their alternate digital sums in bases 2 and 3, are:
  n   a(n)  s2(a(n))  s3(a(n))
  --  ----  --------  --------
   1     1         1         1
   2     2        -1         2
   3     3         0        -1
   4     4         1         0
   5     5         2         1
   6    10        -2         2
   7     6         0        -2
   8     8        -1         0
   9     7         1        -1
  10     9         0         1
  11    11        -1         3
  12    12         0         0
  13    13         1         1
  14    14        -1         2
  15    15         0        -1
  16    16         1         0
  17    17         2         1
  18    18         0         2
  19    19         1         3
  20    20         2         4
		

Crossrefs

Programs

  • PARI
    \\ See Links section.

A065079 Primes > 3 for which the alternating bit sum (A065359) is not equal to 1 or 2.

Original entry on oeis.org

11, 41, 43, 47, 59, 107, 131, 137, 139, 163, 167, 173, 179, 191, 227, 233, 239, 251, 277, 337, 349, 373, 419, 431, 443, 491, 521, 523, 547, 557, 563, 569, 571, 587, 617, 619, 641, 643, 647, 653, 659, 673, 677, 683, 691, 701, 719, 739, 743, 751, 761, 809
Offset: 1

Views

Author

Robert G. Wilson v, Nov 08 2001

Keywords

Comments

Differs from A065049 beginning with 683.

Examples

			11 is in the sequence because 11d = 1011b, so the alternating digits sum of 11 is 1 -1 +0 -1 = -1 which is neither 1 nor 2.
		

References

  • William Paulsen, wpaulsen(AT)csm.astate.edu, personal communication.

Crossrefs

Cf. A065049.

Programs

  • Mathematica
    Do[d = Reverse[ IntegerDigits[ Prime[n], 2]]; l = Length[d]; s = 0; k = 1; While[k < l + 1, s = s - (-1)^k*d[[k]]; k++ ]; If[s != 1 && s != 2, Print[ Prime[n]]], {n, 3, 141} ]
  • PARI
    baseE(x, b)= { local(d, e=0, f=1); while (x>0, d=x-b*(x\b); x\=b; e+=d*f; f*=10); return(e) } SumAD(x)= { local(a=1, s=0); while (x>9, s+=a*(x-10*(x\10)); x\=10; a=-a); return(s + a*x) } { n=0; for (m=3, 10^9, p=prime(m); s=SumAD(baseE(p, 2)); if (s!=1 && s!=2, write("b065079.txt", n++, " ", p); if (n==1000, return)) ) } \\ Harry J. Smith, Oct 06 2009
    
  • PARI
    f(p)={s=0;u=1;for(k=0,#binary(p)-1,s+=bittest(p,k)*u;u=-u);return(s)};forprime(p=5,809,F=f(p);if((F!=1)&&(F!=2),print1(p,", "))) \\ Washington Bomfim, Jan 18 2011

Extensions

"> 3" added to definition by Harry J. Smith, Oct 06 2009

A002450 a(n) = (4^n - 1)/3.

Original entry on oeis.org

0, 1, 5, 21, 85, 341, 1365, 5461, 21845, 87381, 349525, 1398101, 5592405, 22369621, 89478485, 357913941, 1431655765, 5726623061, 22906492245, 91625968981, 366503875925, 1466015503701, 5864062014805, 23456248059221, 93824992236885, 375299968947541
Offset: 0

Views

Author

Keywords

Comments

For n > 0, a(n) is the degree (n-1) "numbral" power of 5 (see A048888 for the definition of numbral arithmetic). Example: a(3) = 21, since the numbral square of 5 is 5(*)5 = 101(*)101(base 2) = 101 OR 10100 = 10101(base 2) = 21, where the OR is taken bitwise. - John W. Layman, Dec 18 2001
a(n) is composite for all n > 2 and has factors x, (3*x + 2*(-1)^n) where x belongs to A001045. In binary the terms greater than 0 are 1, 101, 10101, 1010101, etc. - John McNamara, Jan 16 2002
Number of n X 2 binary arrays with path of adjacent 1's from upper left corner to right column. - R. H. Hardin, Mar 16 2002
The Collatz-function iteration started at a(n), for n >= 1, will end at 1 after 2*n+1 steps. - Labos Elemer, Sep 30 2002 [corrected by Wolfdieter Lang, Aug 16 2021]
Second binomial transform of A001045. - Paul Barry, Mar 28 2003
All members of sequence are also generalized octagonal numbers (A001082). - Matthew Vandermast, Apr 10 2003
Also sum of squares of divisors of 2^(n-1): a(n) = A001157(A000079(n-1)), for n > 0. - Paul Barry, Apr 11 2003
Binomial transform of A000244 (with leading zero). - Paul Barry, Apr 11 2003
Number of walks of length 2n between two vertices at distance 2 in the cycle graph C_6. For n = 2 we have for example 5 walks of length 4 from vertex A to C: ABABC, ABCBC, ABCDC, AFABC and AFEDC. - Herbert Kociemba, May 31 2004
Also number of walks of length 2n + 1 between two vertices at distance 3 in the cycle graph C_12. - Herbert Kociemba, Jul 05 2004
a(n+1) is the number of steps that are made when generating all n-step random walks that begin in a given point P on a two-dimensional square lattice. To make one step means to mark one vertex on the lattice (compare A080674). - Pawel P. Mazur (Pawel.Mazur(AT)pwr.wroc.pl), Mar 13 2005
a(n+1) is the sum of square divisors of 4^n. - Paul Barry, Oct 13 2005
a(n+1) is the decimal number generated by the binary bits in the n-th generation of the Rule 250 elementary cellular automaton. - Eric W. Weisstein, Apr 08 2006
a(n-1) / a(n) = percentage of wasted storage if a single image is stored as a pyramid with a each subsequent higher resolution layer containing four times as many pixels as the previous layer. n is the number of layers. - Victor Brodsky (victorbrodsky(AT)gmail.com), Jun 15 2006
k is in the sequence if and only if C(4k + 1, k) (A052203) is odd. - Paul Barry, Mar 26 2007
This sequence also gives the number of distinct 3-colorings of the odd cycle C(2*n - 1). - Keith Briggs, Jun 19 2007
All numbers of the form m*4^m + (4^m-1)/3 have the property that they are sums of two squares and also their indices are the sum of two squares. This follows from the identity m*4^m + (4^m-1)/3 = 4(4(..4(4m + 1) + 1) + 1) + 1 ..) + 1. - Artur Jasinski, Nov 12 2007
For n > 0, terms are the numbers that, in base 4, are repunits: 1_4, 11_4, 111_4, 1111_4, etc. - Artur Jasinski, Sep 30 2008
Let A be the Hessenberg matrix of order n, defined by: A[1, j] = 1, A[i, i] := 5, (i > 1), A[i, i - 1] = -1, and A[i, j] = 0 otherwise. Then, for n >= 1, a(n) = charpoly(A,1). - Milan Janjic, Jan 27 2010
This is the sequence A(0, 1; 3, 4; 2) = A(0, 1; 4, 0; 1) of the family of sequences [a, b : c, d : k] considered by G. Detlefs, and treated as A(a, b; c, d; k) in the W. Lang link given below. - Wolfdieter Lang, Oct 18 2010
6*a(n) + 1 is every second Mersenne number greater than or equal to M3, hence all Mersenne primes greater than M2 must be a 6*a(n) + 1 of this sequence. - Roderick MacPhee, Nov 01 2010
Smallest number having alternating bit sum n. Cf. A065359.
For n = 1, 2, ..., the last digit of a(n) is 1, 5, 1, 5, ... . - Washington Bomfim, Jan 21 2011
Rule 50 elementary cellular automaton generates this sequence. This sequence also appears in the second column of array in A173588. - Paul Muljadi, Jan 27 2011
Sequence found by reading the line from 0, in the direction 0, 5, ... and the line from 1, in the direction 1, 21, ..., in the square spiral whose edges are the Jacobsthal numbers A001045 and whose vertices are the numbers A000975. These parallel lines are two semi-diagonals in the spiral. - Omar E. Pol, Sep 10 2011
a(n), n >= 1, is also the inverse of 3, denoted by 3^(-1), Modd(2^(2*n - 1)). For Modd n see a comment on A203571. E.g., a(2) = 5, 3 * 5 = 15 == 1 (Modd 8), because floor(15/8) = 1 is odd and -15 == 1 (mod 8). For n = 1 note that 3 * 1 = 3 == 1 (Modd 2) because floor(3/2) = 1 and -3 == 1 (mod 2). The inverse of 3 taken Modd 2^(2*n) coincides with 3^(-1) (mod 2^(2*n)) given in A007583(n), n >= 1. - Wolfdieter Lang, Mar 12 2012
If an AVL tree has a leaf at depth n, then the tree can contain no more than a(n+1) nodes total. - Mike Rosulek, Nov 20 2012
Also, this is the Lucas sequence V(5, 4). - Bruno Berselli, Jan 10 2013
Also, for n > 0, a(n) is an odd number whose Collatz trajectory contains no odd number other than n and 1. - Jayanta Basu, Mar 24 2013
Sum_{n >= 1} 1/a(n) converges to (3*(log(4/3) - QPolyGamma[0, 1, 1/4]))/log(4) = 1.263293058100271... = A321873. - K. G. Stier, Jun 23 2014
Consider n spheres in R^n: the i-th one (i=1, ..., n) has radius r(i) = 2^(1-i) and the coordinates of its center are (0, 0, ..., 0, r(i), 0, ..., 0) where r(i) is in position i. The coordinates of the intersection point in the positive orthant of these spheres are (2/a(n), 4/a(n), 8/a(n), 16/a(n), ...). For example in R^2, circles centered at (1, 0) and (0, 1/2), and with radii 1 and 1/2, meet at (2/5, 4/5). - Jean M. Morales, May 19 2015
From Peter Bala, Oct 11 2015: (Start)
a(n) gives the values of m such that binomial(4*m + 1,m) is odd. Cf. A003714, A048716, A263132.
2*a(n) = A020988(n) gives the values of m such that binomial(4*m + 2, m) is odd.
4*a(n) = A080674(n) gives the values of m such that binomial(4*m + 4, m) is odd. (End)
Collatz Conjecture Corollary: Except for powers of 2, the Collatz iteration of any positive integer must eventually reach a(n) and hence terminate at 1. - Gregory L. Simay, May 09 2016
Number of active (ON, black) cells at stage 2^n - 1 of the two-dimensional cellular automaton defined by "Rule 598", based on the 5-celled von Neumann neighborhood. - Robert Price, May 16 2016
From Luca Mariot and Enrico Formenti, Sep 26 2016: (Start)
a(n) is also the number of coprime pairs of polynomials (f, g) over GF(2) where both f and g have degree n + 1 and nonzero constant term.
a(n) is also the number of pairs of one-dimensional binary cellular automata with linear and bipermutive local rule of neighborhood size n+1 giving rise to orthogonal Latin squares of order 2^m, where m is a multiple of n. (End)
Except for 0, 1 and 5, all terms are Brazilian repunits numbers in base 4, and so belong to A125134. For n >= 3, all these terms are composite because a(n) = {(2^n-1) * (2^n + 1)}/3 and either (2^n - 1) or (2^n + 1) is a multiple of 3. - Bernard Schott, Apr 29 2017
Given the 3 X 3 matrix A = [2, 1, 1; 1, 2, 1; 1, 1, 2] and the 3 X 3 unit matrix I_3, A^n = a(n)(A - I_3) + I_3. - Nicolas Patrois, Jul 05 2017
The binary expansion of a(n) (n >= 1) consists of n 1's alternating with n - 1 0's. Example: a(4) = 85 = 1010101_2. - Emeric Deutsch, Aug 30 2017
a(n) (n >= 1) is the viabin number of the integer partition [n, n - 1, n - 2, ..., 2, 1] (for the definition of viabin number see comment in A290253). Example: a(4) = 85 = 1010101_2; consequently, the southeast border of the Ferrers board of the corresponding integer partition is ENENENEN, where E = (1, 0), N = (0, 1); this leads to the integer partition [4, 3, 2, 1]. - Emeric Deutsch, Aug 30 2017
Numbers whose binary and Gray-code representations are both palindromes (i.e., intersection of A006995 and A281379). - Amiram Eldar, May 17 2021
Starting with n = 1 the sequence satisfies {a(n) mod 6} = repeat{1, 5, 3}. - Wolfdieter Lang, Jan 14 2022
Terms >= 5 are those q for which the multiplicative order of 2 mod q is floor(log_2(q)) + 2 (and which is 1 more than the smallest possible order for any q). - Tim Seuré, Mar 09 2024
The order of 2 modulo a(n) is 2*n for n >= 2. - Joerg Arndt, Mar 09 2024

Examples

			Apply Collatz iteration to 9: 9, 28, 14, 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5 and hence 16, 8, 4, 2, 1.
Apply Collatz iteration to 27: 27, 82, 41, 124, 62, 31, 94, 47, 142, 71, 214, 107, 322, 161, 484, 242, 121, 364, 182, 91, 274, 137, 412, 206, 103, 310, 155, 466, 233, 700, 350, 175, 526, 263, 790, 395, 1186, 593, 1780, 890, 445, 1336, 668, 334, 167, 502, 251, 754, 377, 1132, 566, 283, 850, 425, 1276, 638, 319, 958, 479, 1438, 719, 2158, 1079, 3238, 1619, 4858, 2429, 7288, 3644, 1822, 911, 2734, 1367, 4102, 2051, 6154, 3077, 9232, 4616, 2308, 1154, 577, 1732, 866, 433, 1300, 650, 325, 976, 488, 244, 122, 61, 184, 92, 46, 23, 70, 35, 106, 53, 160, 80, 40, 20, 10, 5 and hence 16, 8, 4, 2, 1. [Corrected by _Sean A. Irvine_ at the suggestion of Stephen Cornelius, Mar 04 2024]
a(5) = (4^5 - 1)/3 = 341 = 11111_4 = {(2^5 - 1) * (2^5 + 1)}/3 = 31 * 33/3 = 31 * 11. - _Bernard Schott_, Apr 29 2017
		

References

  • A. Fletcher, J. C. P. Miller, L. Rosenhead and L. J. Comrie, An Index of Mathematical Tables. Vols. 1 and 2, 2nd ed., Blackwell, Oxford and Addison-Wesley, Reading, MA, 1962, Vol. 1, p. 112.
  • J. Riordan, Combinatorial Identities, Wiley, 1968, p. 217.
  • N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Partial sums of powers of 4, A000302.
When converted to binary, this gives A094028.
Subsequence of A003714.
Primitive factors: A129735.

Programs

  • GAP
    List([0..25], n -> (4^n-1)/3); # Muniru A Asiru, Feb 18 2018
    
  • Haskell
    a002450 = (`div` 3) . a024036
    a002450_list = iterate ((+ 1) . (* 4)) 0
    -- Reinhard Zumkeller, Oct 03 2012
    
  • Magma
    [ (4^n-1)/3: n in [0..25] ]; // Klaus Brockhaus, Oct 28 2008
    
  • Magma
    [n le 2 select n-1 else 5*Self(n-1)-4*Self(n-2): n in [1..70]]; // Vincenzo Librandi, Jun 13 2015
    
  • Maple
    [seq((4^n-1)/3,n=0..40)];
    A002450:=1/(4*z-1)/(z-1); # Simon Plouffe in his 1992 dissertation, dropping the initial zero
  • Mathematica
    Table[(4^n - 1)/3, {n, 0, 127}] (* Vladimir Joseph Stephan Orlovsky, Sep 29 2008 *)
    LinearRecurrence[{5, -4}, {0, 1}, 30] (* Harvey P. Dale, Jun 23 2013 *)
  • Maxima
    makelist((4^n-1)/3, n, 0, 30); /* Martin Ettl, Nov 05 2012 */
    
  • PARI
    a(n) = (4^n-1)/3;
    
  • PARI
    my(z='z+O('z^40)); Vec(z/((1-z)*(1-4*z))) \\ Altug Alkan, Oct 11 2015
    
  • Python
    def A002450(n): return ((1<<(n<<1))-1)//3 # Chai Wah Wu, Jan 29 2023
  • Scala
    ((List.fill(20)(4: BigInt)).scanLeft(1: BigInt)( * )).scanLeft(0: BigInt)( + ) // Alonso del Arte, Sep 17 2019
    

Formula

From Wolfdieter Lang, Apr 24 2001: (Start)
a(n+1) = Sum_{m = 0..n} A060921(n, m).
G.f.: x/((1-x)*(1-4*x)). (End)
a(n) = Sum_{k = 0..n-1} 4^k; a(n) = A001045(2*n). - Paul Barry, Mar 17 2003
E.g.f.: (exp(4*x) - exp(x))/3. - Paul Barry, Mar 28 2003
a(n) = (A007583(n) - 1)/2. - N. J. A. Sloane, May 16 2003
a(n) = A000975(2*n)/2. - N. J. A. Sloane, Sep 13 2003
a(n) = A084160(n)/2. - N. J. A. Sloane, Sep 13 2003
a(n+1) = 4*a(n) + 1, with a(0) = 0. - Philippe Deléham, Feb 25 2004
a(n) = Sum_{i = 0..n-1} C(2*n - 1 - i, i)*2^i. - Mario Catalani (mario.catalani(AT)unito.it), Jul 23 2004
a(n+1) = Sum_{k = 0..n} binomial(n+1, k+1)*3^k. - Paul Barry, Aug 20 2004
a(n) = center term in M^n * [1 0 0], where M is the 3 X 3 matrix [1 1 1 / 1 3 1 / 1 1 1]. M^n * [1 0 0] = [A007583(n-1) a(n) A007583(n-1)]. E.g., a(4) = 85 since M^4 * [1 0 0] = [43 85 43] = [A007583(3) a(4) A007583(3)]. - Gary W. Adamson, Dec 18 2004
a(n) = Sum_{k = 0..n, j = 0..n} C(n, j)*C(j, k)*A001045(j - k). - Paul Barry, Feb 15 2005
a(n) = Sum_{k = 0..n} C(n, k)*A001045(n-k)*2^k = Sum_{k = 0..n} C(n, k)*A001045(k)*2^(n-k). - Paul Barry, Apr 22 2005
a(n) = A125118(n, 3) for n > 2. - Reinhard Zumkeller, Nov 21 2006
a(n) = Sum_{k = 0..n} 2^(n - k)*A128908(n, k), n >= 1. - Philippe Deléham, Oct 19 2008
a(n) = Sum_{k = 0..n} A106566(n, k)*A100335(k). - Philippe Deléham, Oct 30 2008
If we define f(m, j, x) = Sum_{k = j..m} binomial(m, k)*stirling2(k, j)*x^(m - k) then a(n-1) = f(2*n, 4, -2), n >= 2. - Milan Janjic, Apr 26 2009
a(n) = A014551(n) * A001045(n). - R. J. Mathar, Jul 08 2009
a(n) = 4*a(n-1) + a(n-2) - 4*a(n-3) = 5*a(n-1) - 4*a(n-2), a(0) = 0, a(1) = 1, a(2) = 5. - Wolfdieter Lang, Oct 18 2010
a(0) = 0, a(n+1) = a(n) + 2^(2*n). - Washington Bomfim, Jan 21 2011
A036555(a(n)) = 2*n. - Reinhard Zumkeller, Jan 28 2011
a(n) = Sum_{k = 1..floor((n+2)/3)} C(2*n + 1, n + 2 - 3*k). - Mircea Merca, Jun 25 2011
a(n) = Sum_{i = 1..n} binomial(2*n + 1, 2*i)/3. - Wesley Ivan Hurt, Mar 14 2015
a(n+1) = 2^(2*n) + a(n), a(0) = 0. - Ben Paul Thurston, Dec 27 2015
a(k*n)/a(n) = 1 + 4^n + ... + 4^((k-1)*n). - Gregory L. Simay, Jun 09 2016
Dirichlet g.f.: (PolyLog(s, 4) - zeta(s))/3. - Ilya Gutkovskiy, Jun 26 2016
A000120(a(n)) = n. - André Dalwigk, Mar 26 2018
a(m) divides a(m*n), in particular: a(2*n) == 0 (mod 5), a(3*n) == 0 (mod 3*7), a(5*n) == 0 (mod 11*31), etc. - M. F. Hasler, Oct 19 2018
a(n) = 4^(n-1) + a(n-1). - Bob Selcoe, Jan 01 2020
a(n) = A178415(1, n) = A347834(1, n-1), arrays, for n >= 1. - Wolfdieter Lang, Nov 29 2021
a(n) = A000225(2*n)/3. - John Keith, Jan 22 2022
a(n) = A080674(n) + 1 = A047849(n) - 1 = A163834(n) - 2 = A155701(n) - 3 = A163868(n) - 4 = A156605(n) - 7. - Ray Chandler, Jun 16 2023
From Peter Bala, Jul 23 2025: (Start)
The following are examples of telescoping products. Cf. A016153:
Product_{k = 1..2*n} 1 + 2^k/a(k+1) = a(n+1)/A007583(n) = (4^(n+1) - 1)/(2*4^n + 1).
Hence, Product_{k >= 1} 1 + 2^k/a(k+1) = 2.
Product_{k >= 1} 1 - 2^k/a(k+1) = 2/5, since 1 - 2^n/a(n+1) = b(n)/b(n-1), where b(n) = 2 - 3/(1 - 2^(n+1)).
Product_{k >= 1} 1 + (-2)^k/a(k+1) = 2/3, since 1 + (-2)^n/a(n+1) = c(n)/c(n-1), where c(n) = 2 - 1/(1 + (-2)^(n+1)).
Product_{k >= 1} 1 - (-2)^k/a(k+1) = 6/5, since 1 - (-2)^n/a(n+1) = d(n)/d(n-1), where d(n) = 2 - 1/(1 - (-2)^(n+1)). (End)
Showing 1-10 of 43 results. Next