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 32 results. Next

A175077 Final number reached by iterating r -> A049711(r) starting at r = n.

Original entry on oeis.org

1, 2, 1, 1, 2, 1, 2, 1, 2, 1, 1, 1, 2, 1, 2, 1, 1, 1, 2, 1, 2, 1, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 1, 2, 1, 2, 1, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 1, 2, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 1, 1, 2, 1, 2, 1
Offset: 1

Views

Author

Jaroslav Krizek, Jan 23 2010

Keywords

Comments

See A175071 for starting n that reach 1, and A175072 for starting n that reach 2.

Examples

			Iteration procedure for n = 6: 6 mod 5 = 1 = a(6).
Iteration procedure for n = 7: 7 mod 5 = 2 = a(7).
		

Crossrefs

Programs

  • Maple
    A151799 := proc(n) prevprime(n) ; end proc:
    A049711 := proc(n) if n <=2 then n; else n-A151799(n) ; end if; end proc:
    A175077 := proc(n) local r ; r := n ; while r > 2 do r := A049711(r) ; end do: r ; end proc:
    seq(A175077(n),n=1..100) ; # R. J. Mathar, Feb 19 2010
  • Mathematica
    f[n_] := Switch[n, 1, 1, 2, 2, _, n - NextPrime[n, -1]];
    a[n_] := FixedPoint[f, n];
    Table[a[n], {n, 1, 100}] (* Jean-François Alcover, Jun 13 2023 *)

Formula

a(A175071(k)) = 1; a(A175072(k)) = 2, any k. - R. J. Mathar, Feb 19 2010
a(n) = A121559(n-1) + 1 for n >= 2. - Pontus von Brömssen, Jul 31 2022

Extensions

More terms from R. J. Mathar, Feb 19 2010

A013603 Difference between 2^n and the nearest prime less than or equal to 2^n.

Original entry on oeis.org

0, 1, 1, 3, 1, 3, 1, 5, 3, 3, 9, 3, 1, 3, 19, 15, 1, 5, 1, 3, 9, 3, 15, 3, 39, 5, 39, 57, 3, 35, 1, 5, 9, 41, 31, 5, 25, 45, 7, 87, 21, 11, 57, 17, 55, 21, 115, 59, 81, 27, 129, 47, 111, 33, 55, 5, 13, 27, 55, 93, 1, 57, 25, 59, 49, 5, 19, 23, 19, 35, 231, 93, 69, 35, 97, 15
Offset: 1

Views

Author

James Kilfiger (mapdn(AT)csv.warwick.ac.uk)

Keywords

Comments

If a(n) = 1, then n is prime and 2^n - 1 is a Mersenne prime. - Franz Vrabec, Sep 27 2005
Using the first variant A007917 (rather than A151799) of the prevprime() function, the sequence is well defined for n = 1, with a(1) = 2^1 - prevprime(2^1) = 2 - 2 = 0. - M. F. Hasler, Sep 09 2015
In Mathematica, one can use NextPrime with a second argument of -1 to obtain the next smaller prime. As almost all the powers of 2 are composite, this produces the proper results for most of this sequence. However, NextPrime[2, -1] returns -2 rather than the expected 2, which would consequently mean a(1) = 4 rather than 0. - Alonso del Arte, Dec 10 2016

Crossrefs

Equivalent sequence for next prime: A092131.

Programs

  • Maple
    seq(2^i-prevprime(2^i),i=2..100);
  • Mathematica
    {0} ~Join~ Array[With[{c = 2^#}, c - NextPrime[c, -1]] &, 80, 2] (* Harvey P. Dale, Jul 23 2013 *)
    Table[2^n - Prime[PrimePi[2^n]], {n, 80}] (* Alonso del Arte, Dec 10 2016 *)
  • PARI
    a(n) = 2^n - precprime(2^n); \\ Michel Marcus, Apr 04 2020

Formula

a(n) = A049711(2^n). - R. J. Mathar, Nov 28 2016
a(n) = 2^n - prevprime(2^n) = 2^n - prime(primepi(2^n)). - Alonso del Arte, Dec 10 2016

Extensions

Extended to a(1) = 0 by M. F. Hasler, Sep 09 2015

A064722 a(1) = 0; for n >= 2, a(n) = n - (largest prime <= n).

Original entry on oeis.org

0, 0, 0, 1, 0, 1, 0, 1, 2, 3, 0, 1, 0, 1, 2, 3, 0, 1, 0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 0, 1, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 0, 1, 0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 0, 1, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 0, 1, 0, 1, 2, 3
Offset: 1

Views

Author

Reinhard Zumkeller, Oct 13 2001

Keywords

Examples

			a(26) = 26 - 23 = 3, a(37) = 37 - 37 = 0.
		

Crossrefs

Programs

  • Maple
    0, seq(n - prevprime(n+1), n=2..100); # Robert Israel, Aug 25 2014
  • Mathematica
    Join[{0},Table[n-NextPrime[n+1,-1],{n,2,110}]] (* Harvey P. Dale, Aug 23 2011 *)
  • PARI
    { for (n = 1, 1000, if (n>1, a=n - precprime(n), a=0); write("b064722.txt", n, " ", a) ) } \\ Harry J. Smith, Sep 23 2009

Formula

a(n) = n - A007917(n).
a(n) = 0 iff n is 1 or a prime.
Computable also as a "commutator": pi(prime(m)) - prime(pi(m)) = A000720(A000040(m))-A000040(A000720(m)). Labels position of composites between 2 consecutive primes. - Labos Elemer, Oct 19 2001
a(n) = a(n-1)*0^A010051(n) + 1 - A010051(n), a(1) = 0. - Reinhard Zumkeller, Mar 23 2006
a(n) = n mod A007917(n). - Michel Marcus, Aug 22 2014
a(n) = A049711(n+1) - 1 for n >= 2. - Pontus von Brömssen, Jul 31 2022

A049653 a(n) = 2*n - prevprime(2*n).

Original entry on oeis.org

1, 1, 1, 3, 1, 1, 3, 1, 1, 3, 1, 3, 5, 1, 1, 3, 5, 1, 3, 1, 1, 3, 1, 3, 5, 1, 3, 5, 1, 1, 3, 5, 1, 3, 1, 1, 3, 5, 1, 3, 1, 3, 5, 1, 3, 5, 7, 1, 3, 1, 1, 3, 1, 1, 3, 1, 3, 5, 7, 9, 11, 13, 1, 3, 1, 3, 5, 1, 1, 3, 5, 7, 9, 1, 1, 3, 5, 1, 3, 5, 1, 3, 1, 3, 5, 1, 3, 5, 1, 1, 3, 5, 7
Offset: 2

Views

Author

Keywords

Crossrefs

Programs

  • Magma
    [2*n - NthPrime(#PrimesUpTo(2*n)): n in [2..50]]; // G. C. Greubel, Dec 05 2017
    
  • Mathematica
    Table[2*n - NextPrime[2*n, -1], {n, 2, 50}] (* G. C. Greubel, Dec 05 2017 *)
  • PARI
    for(n=2,50, print1(2*n - precprime(2*n), ", ")) \\ G. C. Greubel, Dec 05 2017

Formula

a(n) = A049711(2*n). - R. J. Mathar, Oct 26 2015

A175851 a(n) = 1 for noncomposite n, a(n) = n - previousprime(n) + 1 for composite n.

Original entry on oeis.org

1, 1, 1, 2, 1, 2, 1, 2, 3, 4, 1, 2, 1, 2, 3, 4, 1, 2, 1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 1, 2, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 1, 2, 1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 1, 2, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4
Offset: 1

Views

Author

Jaroslav Krizek, Sep 29 2010

Keywords

Comments

Sequence is cardinal and not fractal. Cardinal sequence is sequence with infinitely many times occurring all natural numbers. Fractal sequence is sequence such that when the first instance of each number in the sequence is erased, the original sequence remains.
Ordinal transform of the nextprime function, A151800(1..) = 2, 3, 5, 5, 7, 7, 11, 11, 11, 11, ..., also ordinal transform of A304106. - Antti Karttunen, Jun 09 2018

Crossrefs

Cf. A065358 for another way of visualizing prime gaps.
Cf. A304106 (ordinal transform of this sequence).
Cf. A049711.

Programs

Formula

a(1) = 1, a(n) = n - A007917(n) + 1 for n >= 2. a(1) = 1, a(2) = 1, a(n) = n - A151799(n+1) + 1 for n >= 3.
a(n) = Sum_{i=1..n} floor(pi(i)/pi(n)), for n>1 with pi(n) = A000720(n). - Ridouane Oudra, Jun 24 2024
a(n) = A049711(n+1), for n>1. - Ridouane Oudra, Jul 16 2024

A135528 1, then repeat 1,0.

Original entry on oeis.org

1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0
Offset: 1

Views

Author

N. J. A. Sloane, based on a message from Guy Steele and Don Knuth, Mar 01 2008

Keywords

Comments

This is Guy Steele's sequence GS(2, 1) (see A135416).
2-adic expansion of 1/3 (right to left): 1/3 = ...01010101010101011. - Philippe Deléham, Mar 24 2009
Also, with offset 0, parity of A036467(n-1). - Omar E. Pol, Mar 17 2015
Appears to be the Gilbreath transform of 1,2,3,5,7,11,13,... (A008578). (This is essentially the same as the Gilbreath conjecture, see A036262.) - N. J. A. Sloane, May 08 2023

Examples

			G.f. = x + x^2 + x^4 + x^6 + x^8 + x^10 + x^12 + x^14 + x^16 + x^18 + x^20 + ...
		

Crossrefs

Programs

  • Haskell
    a135528 n = a135528_list !! (n-1)
    a135528_list = concat $ iterate ([1,0] *) [1]
    instance Num a => Num [a] where
    fromInteger k = [fromInteger k]
       (p:ps) + (q:qs) = p + q : ps + qs
       ps + qs         = ps ++ qs
       (0:ps) * qs         = 0 : ps * qs
       (p:ps) * qs'@(q:qs) = p * q : ps * qs' + [p] * qs
        *                = []
    -- Reinhard Zumkeller, Apr 02 2011
  • Maple
    GS(2,1,200); [see A135416].
  • Mathematica
    Prepend[Table[Mod[n + 1, 2], {n, 2, 60}], 1] (* Michael De Vlieger, Mar 17 2015 *)
    PadRight[{1},120,{0,1}] (* Harvey P. Dale, Apr 23 2024 *)

Formula

G.f.: x*(1+x-x^2)/(1-x^2). - Philippe Deléham, Feb 08 2012
G.f.: x / (1 - x / (1 + x / (1 + x / (1 - x)))). - Michael Somos, Apr 02 2012
a(n) = A049711(n+2) mod 2. - Ctibor O. Zizka, Jan 28 2019

A336496 Products of superfactorials (A000178).

Original entry on oeis.org

1, 2, 4, 8, 12, 16, 24, 32, 48, 64, 96, 128, 144, 192, 256, 288, 384, 512, 576, 768, 1024, 1152, 1536, 1728, 2048, 2304, 3072, 3456, 4096, 4608, 6144, 6912, 8192, 9216, 12288, 13824, 16384, 18432, 20736, 24576, 27648, 32768, 34560, 36864, 41472, 49152, 55296
Offset: 1

Views

Author

Gus Wiseman, Aug 03 2020

Keywords

Comments

First differs from A317804 in having 34560, which is the first term with more than two distinct prime factors.

Examples

			The sequence of terms together with their prime indices begins:
    1: {}
    2: {1}
    4: {1,1}
    8: {1,1,1}
   12: {1,1,2}
   16: {1,1,1,1}
   24: {1,1,1,2}
   32: {1,1,1,1,1}
   48: {1,1,1,1,2}
   64: {1,1,1,1,1,1}
   96: {1,1,1,1,1,2}
  128: {1,1,1,1,1,1,1}
  144: {1,1,1,1,2,2}
  192: {1,1,1,1,1,1,2}
  256: {1,1,1,1,1,1,1,1}
  288: {1,1,1,1,1,2,2}
  384: {1,1,1,1,1,1,1,2}
  512: {1,1,1,1,1,1,1,1,1}
		

Crossrefs

A001013 is the version for factorials, with complement A093373.
A181818 is the version for superprimorials, with complement A336426.
A336497 is the complement.
A000178 lists superfactorials.
A001055 counts factorizations.
A006939 lists superprimorials or Chernoff numbers.
A049711 is the minimum prime multiplicity in A000178.
A174605 is the maximum prime multiplicity in A000178.
A303279 counts prime factors of superfactorials.
A317829 counts factorizations of superprimorials.
A322583 counts factorizations into factorials.
A325509 counts factorizations of factorials into factorials.

Programs

  • Mathematica
    supfac[n_]:=Product[k!,{k,n}];
    facsusing[s_,n_]:=If[n<=1,{{}},Join@@Table[Map[Prepend[#,d]&,Select[facsusing[Select[s,Divisible[n/d,#]&],n/d],Min@@#>=d&]],{d,Select[s,Divisible[n,#]&]}]];
    Select[Range[1000],facsusing[Rest[Array[supfac,30]],#]!={}&]

A013604 a(n) = 3^n - prevprime(3^n), where prevprime(x) is the largest prime < x.

Original entry on oeis.org

1, 2, 4, 2, 2, 2, 8, 8, 2, 20, 16, 58, 22, 8, 16, 98, 10, 10, 14, 8, 4, 2, 20, 28, 20, 20, 26, 22, 14, 26, 4, 34, 52, 56, 28, 10, 2, 10, 58, 38, 2, 122, 74, 34, 22, 22, 46, 44, 50, 46, 16, 124, 4, 10, 106, 10, 26, 220, 38, 160, 74, 8, 28, 104, 104, 38, 298, 94, 16
Offset: 1

Views

Author

James Kilfiger (mapdn(AT)csv.warwick.ac.uk)

Keywords

Crossrefs

Programs

  • Magma
    [3^n-PreviousPrime(3^n): n in [1..70]]; // Vincenzo Librandi, Sep 16 2016
    
  • Maple
    seq(3^i-prevprime(3^i),i=1..100);
  • Mathematica
    Table[3^i - NextPrime[3^i, - 1], {i, 70}] (* Vincenzo Librandi, Sep 16 2016 *)
  • PARI
    a(n) = 3^n - precprime(3^n-1); \\ Michel Marcus, Sep 16 2016

Formula

a(n) = A049711(3^n) = A049711(A000244(n)). - Michel Marcus, Sep 16 2016

A049613 a(n) = 2n - (largest prime < 2n-2).

Original entry on oeis.org

3, 3, 3, 5, 3, 3, 5, 3, 3, 5, 3, 5, 7, 3, 3, 5, 7, 3, 5, 3, 3, 5, 3, 5, 7, 3, 5, 7, 3, 3, 5, 7, 3, 5, 3, 3, 5, 7, 3, 5, 3, 5, 7, 3, 5, 7, 9, 3, 5, 3, 3, 5, 3, 3, 5, 3, 5, 7, 9, 11, 13, 15, 3, 5, 3, 5, 7, 3, 3, 5, 7, 9, 11, 3, 3, 5, 7, 3, 5, 7, 3, 5, 3, 5, 7, 3, 5, 7, 3, 3, 5
Offset: 3

Views

Author

David M. Elder (elddm(AT)rhodes.edu)

Keywords

Examples

			a(14)=28 - (largest prime < 26) = 28 - 23 = 5.
		

Crossrefs

Programs

  • Haskell
    a049613 n = 2 * n - a007917 (2 * n - 2)
    -- Reinhard Zumkeller, Jan 02 2015
  • Mathematica
    Table[2n-NextPrime[2n-2,-1],{n,3,100}] (* Harvey P. Dale, Aug 16 2011 *)

Formula

a(n) <= A002373(n). - R. J. Mathar, Mar 19 2008
a(n) = 2*n - A007917(2*n-2). - Reinhard Zumkeller, Jan 02 2015

A049716 a(n) = 2*n + 1 - prevprime(2*n + 1).

Original entry on oeis.org

1, 2, 2, 2, 4, 2, 2, 4, 2, 2, 4, 2, 4, 6, 2, 2, 4, 6, 2, 4, 2, 2, 4, 2, 4, 6, 2, 4, 6, 2, 2, 4, 6, 2, 4, 2, 2, 4, 6, 2, 4, 2, 4, 6, 2, 4, 6, 8, 2, 4, 2, 2, 4, 2, 2, 4, 2, 4, 6, 8, 10, 12, 14, 2, 4, 2, 4, 6, 2, 2, 4, 6, 8, 10, 2, 2, 4, 6, 2, 4, 6, 2, 4, 2, 4, 6, 2, 4, 6, 2, 2, 4
Offset: 1

Views

Author

Keywords

Examples

			n:     1  2  3  4  5  6  7  8 ...
2n+1:  3  5  7  9 11 13 15 17 ...
pp:    2  3  5  7  7 11 13 13 ...
diff:  1  2  2  2  4  2  2  4 ...
		

Crossrefs

Programs

  • Maple
    seq(2*n+1-prevprime(2*n+1), n=1..100); # Robert Israel, Jul 05 2018
  • Mathematica
    Table[2n+1-NextPrime[2n+1,-1],{n,100}] (* Harvey P. Dale, Sep 21 2013 *)
  • PARI
    a(n) = 2*n+1-precprime(2*n); \\ Michel Marcus, Jul 06 2018

Formula

a(n) = A049711(2*n+1). - R. J. Mathar, Oct 26 2015
Showing 1-10 of 32 results. Next