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

A013632 Difference between n and the next prime greater than n.

Original entry on oeis.org

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

Views

Author

Keywords

Comments

Alternatively, a(n) is the smallest positive k such that n + k is prime. - N. J. A. Sloane, Nov 18 2015
Except for a(0) and a(1), a(n) is the least k such that gcd(n!, n + k) = 1. - Robert G. Wilson v, Nov 05 2010
This sequence uses the "strictly larger" variant A151800 of the nextprime function, rather than A007918. Therefore all terms are positive and a(n) = 1 if and only if n + 1 is a prime. - M. F. Hasler, Sep 09 2015
For n > 0, a(n) and n are of opposite parity. Also, by Bertrand's postulate (actually a theorem), for n > 1, a(n) < n. - Zak Seidov, Dec 27 2018

Examples

			a(30) = 1 because 31 is the next prime greater than 30 and 31 - 30 = 1.
a(31) = 6 because 37 is the next prime greater than 31 and 37 - 31 = 6.
		

Crossrefs

Programs

  • Magma
    [NextPrime(n) - n: n in [0..100]]; // Vincenzo Librandi, Dec 27 2018
    
  • Maple
    [ seq(nextprime(i)-i,i=0..100) ];
  • Mathematica
    Array[NextPrime[#] - # &, 105, 0] (* Robert G. Wilson v, Nov 05 2010 *)
  • PARI
    a(n) = nextprime(n+1) - n; \\ Michel Marcus, Mar 04 2015
    
  • SageMath
    [next_prime(n) - n for n in range(121)] # G. C. Greubel, May 12 2023

Formula

a(n) = Prime(1 + PrimePi(n)) - n = A084695(n, 1) (for n > 0). - G. C. Greubel, May 12 2023

Extensions

Incorrect comment removed by Charles R Greathouse IV, Mar 18 2010
More terms from Robert G. Wilson v, Nov 05 2010

A032352 Numbers k such that there is no prime between 10*k and 10*k+9.

Original entry on oeis.org

20, 32, 51, 53, 62, 84, 89, 107, 113, 114, 126, 133, 134, 135, 141, 146, 150, 164, 167, 168, 171, 176, 179, 185, 189, 192, 196, 204, 207, 210, 218, 219, 232, 236, 240, 248, 249, 251, 256, 258, 282, 294, 298, 305, 309, 314, 315, 317, 323, 324, 326, 328, 342
Offset: 1

Views

Author

Keywords

Comments

Numbers k with property that appending any single decimal digit to k does not produce a prime.
A007920(n*10) > 10.

Examples

			m=32: 321=3*107, 323=17*19, 325=5*5*13, 327=3*109, 329=7*47, therefore 32 is a term.
		

Crossrefs

Cf. A124665 (subsequence), A010051, A007811, A216292, A216293.

Programs

  • Haskell
    a032352 n = a032352_list !! (n-1)
    a032352_list = filter
       (\x -> all (== 0) $ map (a010051 . (10*x +)) [1..9]) [1..]
    -- Reinhard Zumkeller, Oct 22 2011
    
  • Magma
    [n: n in [1..350] | IsZero(#PrimesInInterval(10*n, 10*n+9))]; // Bruno Berselli, Sep 04 2012
    
  • Maple
    a:=proc(n) if map(isprime,{seq(10*n+j,j=1..9)})={false} then n else fi end: seq(a(n),n=1..350); # Emeric Deutsch, Aug 01 2005
  • Mathematica
    f[n_] := PrimePi[10n + 10] - PrimePi[10n]; Select[ Range[342], f[ # ] == 0 &] (* Robert G. Wilson v, Sep 24 2004 *)
    Select[Range[342], NextPrime[10 # ] > 10 # + 9 &] (* Maciej Ireneusz Wilczynski, Jul 18 2010 *)
    Flatten@Position[10*#+{1,3,7,9}&/@Range@4000,{?CompositeQ ..}] (* _Hans Rudolf Widmer, Jul 06 2024 *)
  • PARI
    is(n)=!isprime(10*n+1) && !isprime(10*n+3) && !isprime(10*n+7) && !isprime(10*n+9) \\ Charles R Greathouse IV, Mar 29 2013
    
  • Python
    from sympy import isprime
    def aupto(limit):
      alst = []
      for d in range(2, limit+1):
        td = [10*d + j for j in [1, 3, 7, 9]]
        if not any(isprime(t) for t in td): alst.append(d)
      return alst
    print(aupto(342)) # Michael S. Branicky, May 30 2021

Formula

a(n) ~ n. - Charles R Greathouse IV, Mar 29 2013

Extensions

More terms from Miklos Kristof, Aug 27 2002

A104080 Smallest prime >= 2^n.

Original entry on oeis.org

2, 2, 5, 11, 17, 37, 67, 131, 257, 521, 1031, 2053, 4099, 8209, 16411, 32771, 65537, 131101, 262147, 524309, 1048583, 2097169, 4194319, 8388617, 16777259, 33554467, 67108879, 134217757, 268435459, 536870923, 1073741827, 2147483659
Offset: 0

Views

Author

Cino Hilliard, Mar 03 2005

Keywords

Crossrefs

Except initial terms and offset, same as A014210 and A203074.
The opposite (greatest prime <= 2^n) is A014234, indices A007053.
The distance from 2^n is A092131, opposite A013603.
Counting zeros instead of both bits gives A372474, cf. A035103, A211997.
Counting ones instead of both bits gives A372517, cf. A014499, A061712.
For squarefree instead of prime we have A372683, cf. A143658, A372540.
The indices of these prime are given by A372684.

Programs

Formula

a(n) = A014210(n), n <> 1. - R. J. Mathar, Oct 14 2008
Sum_{n >= 0} 1/a(n) = A338475 + 1/6 = 1.4070738... (because 1/6 = 1/2 - 1/3). - Bernard Schott, Nov 01 2020
From Gus Wiseman, Jun 03 2024: (Start)
a(n) = A007918(2^n).
a(n) = 2^n + A092131(n).
a(n) = prime(A372684(n)).
(End)

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

A092131 Distance from 2^n to the next prime.

Original entry on oeis.org

0, 1, 3, 1, 5, 3, 3, 1, 9, 7, 5, 3, 17, 27, 3, 1, 29, 3, 21, 7, 17, 15, 9, 43, 35, 15, 29, 3, 11, 3, 11, 15, 17, 25, 53, 31, 9, 7, 23, 15, 27, 15, 29, 7, 59, 15, 5, 21, 69, 55, 21, 21, 5, 159, 3, 81, 9, 69, 131, 33, 15, 135, 29, 13, 131, 9, 3, 33, 29, 25, 11, 15, 29, 37, 33, 15, 11, 7, 23
Offset: 1

Views

Author

Helmut Richter (richter(AT)lrz.de), Mar 30 2004

Keywords

Comments

Essentially the same as A013597. - T. D. Noe, Jul 17 2007
From Jianing Song, May 28 2024: (Start)
Not every odd number is present, as no term can be equal to a Sierpiński number (for example 78557); cf. A076336. See also A067760.
Conjecture: Every odd number which is not a Sierpiński number is a term. In other words, for every odd k which is not a Sierpiński number, there exists some n >= 1 such that 2^n + 1, 2^n + 3, ..., 2^n + (k-2) are all composite while 2^n + k is prime. (End)

Examples

			a(13)=17 because 2^13=8192 and the next prime is 8209=8192+17.
		

Crossrefs

Cf. A013597.
Equivalent sequence for previous prime: A013603.

Programs

  • Mathematica
    Join[{0},NextPrime[#]-#&/@(2^Range[2,80])] (* Harvey P. Dale, Jun 06 2012 *)
  • PARI
    for(i=1,100,x=2^i;print1(nextprime(x)-x,","))

Formula

a(n) = nextprime(2^n) - 2^n.
a(n) = A007920(A000079(n)). - Michel Marcus, Oct 19 2022

A378371 Distance between n and the least non prime power >= n, allowing 1.

Original entry on oeis.org

0, 4, 3, 2, 1, 0, 3, 2, 1, 0, 1, 0, 1, 0, 0, 2, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 2, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0
Offset: 1

Views

Author

Gus Wiseman, Nov 28 2024

Keywords

Comments

Non prime powers allowing 1 (A361102) are numbers that are not a prime power (A246655), namely 1, 6, 10, 12, 14, 15, 18, 20, 21, 22, 24, ...

Examples

			The least non prime power >= 4 is 6, so a(4) = 2.
		

Crossrefs

Sequences obtained by adding n to each term are placed in parentheses below.
For prime we have A007920 (A151800), strict A013632.
For composite we have A010051 (A113646 except initial terms).
For perfect power we have A074984 (A377468)
For squarefree we have A081221 (A067535).
For nonsquarefree we have (A120327).
For non perfect power we have A378357 (A378358).
The opposite version is A378366 (A378367).
For prime power we have A378370, strict A377282 (A000015).
This sequence is A378371 (A378372).
A000040 lists the primes, differences A001223.
A000961 and A246655 list the prime powers, differences A057820.
A024619 and A361102 list the non prime powers, differences A375708 and A375735.
Prime powers between primes: A053607, A080101, A304521, A366833, A377057.

Programs

  • Mathematica
    Table[NestWhile[#+1&,n,PrimePowerQ[#]&]-n,{n,100}]

Formula

a(n) = A378372(n) - n.

A378372 Least non prime power >= n, allowing 1.

Original entry on oeis.org

1, 6, 6, 6, 6, 6, 10, 10, 10, 10, 12, 12, 14, 14, 15, 18, 18, 18, 20, 20, 21, 22, 24, 24, 26, 26, 28, 28, 30, 30, 33, 33, 33, 34, 35, 36, 38, 38, 39, 40, 42, 42, 44, 44, 45, 46, 48, 48, 50, 50, 51, 52, 54, 54, 55, 56, 57, 58, 60, 60, 62, 62, 63, 65, 65, 66, 68
Offset: 1

Views

Author

Gus Wiseman, Nov 29 2024

Keywords

Comments

Non prime powers allowing 1 (A361102) are numbers that are not a prime power (A246655), namely 1, 6, 10, 12, 14, 15, 18, 20, 21, 22, 24, ...

Examples

			The least non prime power >= 4 is 6, so a(4) = 6.
		

Crossrefs

Sequences obtained by subtracting n from each term are placed in parentheses below.
For prime power we have A000015 (A378370).
For squarefree we have A067535 (A081221).
For composite we have A113646 (A010051).
For nonsquarefree we have A120327.
For prime we have A151800 (A007920), strict (A013632).
Run-lengths are 1 and A375708.
For perfect power we have A377468 (A074984).
For non-perfect power we have A378358 (A378357).
The opposite is A378367, distance A378366.
This sequence is A378372 (A378371).
A000040 lists the primes, differences A001223.
A000961 and A246655 list the prime powers, differences A057820.
A024619 and A361102 list the non prime powers, differences A375708 and A375735.
Prime powers between primes: A053607, A080101, A304521, A366833, A377057.

Programs

  • Mathematica
    Table[NestWhile[#+1&,n,PrimePowerQ[#]&],{n,100}]

Formula

a(n) = A378371(n) + n.

A074984 m^p-n, for smallest m^p>=n.

Original entry on oeis.org

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

Views

Author

Zak Seidov, Oct 07 2002

Keywords

Comments

a(n) = 0 if n = m^p that is if n is a full power (square, cube etc.).
This is the distance between n and the next perfect power. The previous perfect power is A081676, which differs from n by A069584. After a(8) = a(9) this sequence is an anti-run (no adjacent equal terms). - Gus Wiseman, Dec 02 2024

Crossrefs

Sequences obtained by subtracting n from each term are placed in parentheses below.
Positions of 0 are A001597.
Positions of 1 are A375704.
The version for primes is A007920 (A007918).
The opposite (greatest perfect power <= n) is A069584 (A081676).
The version for perfect powers is A074984 (this) (A377468).
The version for squarefree numbers is A081221 (A067535).
The version for non perfect powers is A378357 (A378358).
The version for nonsquarefree numbers is A378369 (A120327).
The version for prime powers is A378370 (A000015).
The version for non prime powers is A378371 (A378372).
A001597 lists the perfect powers, differences A053289.
A007916 lists the non perfect powers, differences A375706.
A069623 counts perfect powers <= n.
A076411 counts perfect powers < n.
A131605 lists perfect powers that are not prime powers.
A377432 counts perfect powers between primes, zeros A377436.

Programs

  • Mathematica
    powerQ[n_] := GCD @@ FactorInteger[n][[All, 2]] > 1; powerQ[1] = True; a[n_] := For[k = n, True, k++, If[powerQ[k], Return[k-n]]]; Table[a[n], {n, 1, 92}] (* Jean-François Alcover, Apr 19 2013 *)
  • PARI
    a(n) = { if (n==1, return (0)); my(nn = n); while(! ispower(nn), nn++); return (nn - n);} \\ Michel Marcus, Apr 19 2013

Formula

a(n) = A377468(n) - n. - Gus Wiseman, Dec 02 2024

A378357 Distance from n to the least non perfect power >= n.

Original entry on oeis.org

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

Views

Author

Gus Wiseman, Nov 24 2024

Keywords

Comments

Perfect powers (A001597) are 1 and numbers with a proper integer root, complement A007916.
All terms are <= 2 because the only adjacent perfect powers are 8 and 9.

Crossrefs

The version for prime numbers is A007920, subtraction of A159477 or A007918.
The version for perfect powers is A074984, subtraction of A377468.
The version for squarefree numbers is A081221, subtraction of A067535.
Subtracting from n gives A378358, opposite A378363.
The opposite version is A378364.
The version for nonsquarefree numbers is A378369, subtraction of A120327.
The version for prime powers is A378370, subtraction of A000015.
The version for non prime powers is A378371, subtraction of A378372.
The version for composite numbers is A378456, subtraction of A113646.
A000961 lists the powers of primes, differences A057820.
A001597 lists the perfect powers, differences A053289, seconds A376559.
A007916 lists the non perfect powers, differences A375706, seconds A376562.
A069623 counts perfect powers <= n.
A076411 counts perfect powers < n.
A377432 counts perfect powers between primes, zeros A377436.

Programs

  • Mathematica
    perpowQ[n_]:=n==1||GCD@@FactorInteger[n][[All,2]]>1;
    Table[NestWhile[#+1&,n,#>1&&perpowQ[#]&]-n,{n,100}]
  • Python
    from sympy import perfect_power
    def A378357(n): return 0 if n>1 and perfect_power(n)==False else 1 if perfect_power(n+1)==False else 2 # Chai Wah Wu, Nov 27 2024

Formula

a(n) = n - A378358(n).

A378370 Distance between n and the least prime power >= n, allowing 1.

Original entry on oeis.org

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

Views

Author

Gus Wiseman, Nov 27 2024

Keywords

Comments

Prime powers allowing 1 are listed by A000961.

Crossrefs

Sequences obtained by adding n to each term are placed in parentheses below.
For prime instead of prime power we have A007920 (A007918), strict A013632.
For perfect power we have A074984 (A377468), opposite A069584 (A081676).
For squarefree we have A081221 (A067535).
The restriction to the prime numbers is A377281 (A345531).
The strict version is A377282 = a(n) + 1.
For non prime power instead of prime power we have A378371 (A378372).
The opposite version is A378457, strict A276781.
A000015 gives the least prime power >= n, opposite A031218.
A000040 lists the primes, differences A001223.
A000961 and A246655 list the prime powers, differences A057820.
A024619 and A361102 list the non prime powers, differences A375708 and A375735.
A151800 gives the least prime > n.
Prime-powers between primes: A053607, A080101, A304521, A366833, A377057.

Programs

  • Mathematica
    Table[NestWhile[#+1&,n,#>1&&!PrimePowerQ[#]&]-n,{n,100}]

Formula

a(n) = A000015(n) - n.
a(n) = A377282(n - 1) - 1 for n > 1.
Showing 1-10 of 22 results. Next