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

A077019 a(n) is the smallest number for which the prime distance A051699 is equal to n.

Original entry on oeis.org

2, 1, 0, 26, 93, 118, 119, 120, 531, 532, 897, 1140, 1339, 1340, 1341, 1342, 1343, 1344, 9569, 15702, 15703, 15704, 15705, 19632, 19633, 19634, 19635, 31424, 31425, 31426, 31427, 31428, 31429, 31430, 31431, 31432, 31433, 155958, 155959, 155960, 155961, 155962, 155963, 155964
Offset: 0

Views

Author

Eric W. Weisstein, Oct 17 2002

Keywords

Crossrefs

Programs

  • PARI
    d(n) = if(n<1, 2*(n==0), min(nextprime(n)-n, n-precprime(n))); \\ A051699
    a(n) = my(k=0); while (d(k) != n, k++); k; \\ Michel Marcus, Aug 21 2019

Extensions

More terms from Michel Marcus, Aug 21 2019

A110976 Sequence of numerators associated with the continued fraction based on the sequence d(n)= distance of n from closest prime ( A051699).

Original entry on oeis.org

2, 3, 2, 3, 5, 3, 8, 3, 11, 25, 36, 25, 61, 25, 86, 197, 283, 197, 480, 197, 677, 1551, 2228, 1551, 3779, 9109, 31106, 71321, 102427, 71321, 173748, 71321, 245069, 561459, 1929446, 4420351, 6349797, 4420351, 10770148, 25960647, 36730795, 25960647
Offset: 0

Views

Author

Keywords

Comments

The value of the continued fraction (for n to infinity) is 2.77459638163600405370875399896...; A(n) = A(n+2) if d(n) =2 and d(n+2) = 0

Examples

			if n = 2, A(n) = A(2) = 3 because A(0) = 2, A(1) = 1 * A(0) + 1 = 3, as the distances of n from closest prime are 2, 1, 0, 0, 1 ...
		

References

  • G. Balzarotti and P. P. Lava, Le sequenze di numeri interi, Hoepli, 2008, p. 110.

Crossrefs

Programs

  • Maple
    A[0]:=d[0]; A[1]:=d[1]*A[0]+1; B[0]:=1; B[1]:=d[1]*B[0]; for n from 2 by 1 to N do A[n]:=d[n]*A[n-1]+A[n-2]; B[n]:=d[n]*B[n-1]+B[n-2]; od;

Formula

See program

A110977 Sequence of denominators associated with the continued fraction based on the sequence d(n)= distance of n from closest prime ( A051699).

Original entry on oeis.org

1, 1, 1, 1, 2, 1, 3, 1, 4, 9, 13, 9, 22, 9, 31, 71, 102, 71, 173, 71, 244, 559, 803, 559, 1362, 3283, 11211, 25705, 36916, 25705, 62621, 25705, 88326, 202357, 695397, 1593151, 2288548, 1593151, 3881699, 9356549, 13238248, 9356549, 22594797, 9356549
Offset: 0

Views

Author

Keywords

Examples

			if n = 2, B(n) = B(2) = 1 because B(0) = 1, B(1) = 1 * B(0) = 1 as the distances of n from closest prime are 2, 1, 0, 0, 1 ...
		

References

  • G. Balzarotti and P. P. Lava, Le sequenze di numeri interi, Hoepli, 2008, p. 110.

Crossrefs

Programs

  • Maple
    A[0]:=d[0]; A[1]:=d[1]*A[0]+1; B[0]:=1; B[1]:=d[1]*B[0]; for n from 2 by 1 to N do A[n]:=d[n]*A[n-1]+A[n-2]; B[n]:=d[n]*B[n-1]+B[n-2]; od;

Formula

See program.

A359734 Lexicographically earliest sequence of distinct nonnegative integers such that the sequence A051699(a(n)) (distance from the nearest prime) has the same sequence of digits.

Original entry on oeis.org

1, 10, 2, 0, 3, 26, 9, 119, 532, 4, 6, 896, 118, 34, 15, 93, 121, 531, 898, 205, 8, 12, 533, 50, 117, 14, 122, 1078, 56, 16, 21, 18, 144, 64, 20, 895, 1138, 899, 25, 5, 186, 1077, 22, 27, 204, 76, 86, 206, 7, 24, 28, 120, 30, 123, 32, 33, 35, 36, 11, 300
Offset: 0

Views

Author

M. F. Hasler and Eric Angelini, Jan 12 2023

Keywords

Comments

In the definition, "has the same digits" means that the concatenation of the terms yields the same string of digits, for the sequence a(.) and the sequence A051699(a(.)).
Conjectured to be a permutation of the nonnegative integers. The inverse permutation would start (3, 0, 2, 4, 9, 39, 10, 48, 20, 6, 1, 58, 21, 75, 25, 14, ...).

Examples

			Below, row "p" lists the closest prime to a(n) and row "d" the absolute difference |a(n)-p|. We have the same sequence of digits in rows a (this sequence) and d:
  n :  0   1   2   3   4   5   6   7   8   9  10  11  12  13  14 ...
  a :  1  10   2   0   3  26   9  119 532  4   6 896 118  34  15 ...
  p :  2  11   2   2   3  23   7  113 523  3   5 887 113  31  13 ...
  d :  1   1   0   2   0   3   2   6   9   1   1   9   5   3   2 ...
		

Crossrefs

Cf. A051699 (distance from the nearest prime), A000040 (the primes).
Cf. A359736, A359737 (similar for squares and Fibonacci numbers).

Programs

  • PARI
    spine(f, N=20, S=[], d=[], md = n -> if(n, digits(n), [0])) = { vector(N, n, my(m, j=1); for(k=0, oo, setsearch(S, k) && next; while( f(j) < k, j++); m = md(min(m = f(j) - k, iferr(k - f(j-1), E, m))); if(m == concat(d, md(k))[1..#m], d = concat(d, md(k))[#m+1 .. -1]; m=k; break)); S = setunion(S, [m]); m)}
    spine(prime, 200) \\ 200 terms of this sequence

A072926 a(n) = Sum_{k=1..n} A051699(k).

Original entry on oeis.org

1, 1, 1, 2, 2, 3, 3, 4, 6, 7, 7, 8, 8, 9, 11, 12, 12, 13, 13, 14, 16, 17, 17, 18, 20, 23, 25, 26, 26, 27, 27, 28, 30, 33, 35, 36, 36, 37, 39, 40, 40, 41, 41, 42, 44, 45, 45, 46, 48, 51, 53, 54, 54, 55, 57, 60, 62, 63, 63, 64, 64, 65, 67, 70, 72, 73, 73, 74, 76, 77, 77, 78, 78, 79
Offset: 1

Views

Author

Benoit Cloitre, Aug 11 2002

Keywords

Crossrefs

Cf. A051699.

Programs

  • Mathematica
    f[n_] := If[PrimeQ[n], 0, Min[NextPrime[n] - n, n - NextPrime[n, -1]]]; Accumulate[Table[f[n], {n, 1, 100}]] (* Amiram Eldar, May 05 2022 *)
  • PARI
    a(n)=sum(k=1,n,vecmin(vector(k,i,abs(k-prime(i)))))
    
  • Python
    from sympy import nextprime; p = a = 1
    while p < 71:
        q = nextprime(p); h = (q - p)//2
        for i in range(q-p): a += h - abs(h-i); print(a, end = ', ')
        p = q # Ya-Ping Lu, Apr 06 2025

Formula

Conjecture: a(n) is asymptotic to C*n*log(n) with C = 0.29... .
From Ya-Ping Lu, Apr 06 2025: (Start)
C = lim_{n->oo} a(n)/(n*log(n)) = 0.44 approximately.
a(prime(m)) = 1 + Sum_(i=3..m) (1/4)*(prime(i)-prime(i-1))^2. (End)

A110917 Conversion to a regular-simple continued-fraction approximation of the limit value (C0=2.7745963816360040537087...) of the continued fraction (numerator = A110976 and denominator = A110977) based on the sequence of the distances of n from closest primes (A051699).

Original entry on oeis.org

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

Views

Author

Keywords

Comments

With the exception of n = 3, it should be abs(a(n)-a(n-1)) = < 1 for all n. Hill-mountain-like plot, with land = 2.

Examples

			C0 = a(1) +1/( a(2) +1/( a(3) +1/( a(4) +1/( a(5) +...=2+1/(1+1/(3+1/(2+1/(3+...
		

References

  • G. Balzarotti and P. P. Lava, Le sequenze di numeri interi, Hoepli, 2008, p. 110.

Crossrefs

Programs

  • Maple
    cd:=proc(N) # d[n]distance of n from closest prime A[0]:=d[0]; A[1]:=d[1]*A[0]+1; B[0]:=1; B[1]:=d[1]*B[0]; for n from 2 by 1 to N do A[n]:=d[n]*A[n-1]+A[n-2]; B[n]:=d[n]*B[n-1]+B[n-2]; od; R:=A[N]/B[N]; convert(R,confrac); end:

Formula

see program

A308633 Continued fraction for the decimal expansion of the concatenation of the terms of A051699 (distance from n to closest prime).

Original entry on oeis.org

0, 4, 1, 3, 5, 9, 1, 2, 2, 4, 7, 1, 246, 1, 2, 2, 1, 116363868, 3, 1, 1, 1, 3, 4, 282, 1, 1, 1, 2, 1, 8, 2, 1, 1, 1, 1, 7, 10, 7, 1, 2, 1, 6, 2, 1, 2, 7, 2, 11, 1, 3, 1, 4, 1, 4, 1, 3, 5, 9, 1, 1, 1, 3, 3, 1, 3, 2, 1, 5, 3, 3, 1, 32, 1, 1, 15, 3, 1, 1, 11, 9, 1
Offset: 0

Views

Author

Paolo P. Lava, Jun 17 2019

Keywords

Comments

Continued fraction for .2100101012101012101012101232101012321... (see A051699).
Very high value for a(17) = 116363868. This should imply that using the first 16 terms we have a good rational approximation of this decimal expansion: 131256182/624999375 is ok up to the 25th decimal digit.

Crossrefs

Programs

  • Maple
    Digits:=200: with(numtheory): P:=proc(q) local a,b,n; a:=21;
    for n from 2 to q do if isprime(n) then a:=10*a; else
    b:=min(nextprime(n)-n,n-prevprime(n)); a:=a*10^length(b)+b; fi; od;
    op(convert(evalf(a/10^length(a)),confrac,100)); end: P(200);

A080733 Smallest distance from n to a squarefree number.

Original entry on oeis.org

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

Views

Author

Benoit Cloitre, Mar 08 2003

Keywords

Comments

a(n) = min (abs(n-k) : where k runs through the squarefree numbers ).
The sequence is unbounded.
The first 0 occurs at 1, the first 1 at 4, the first 2 at 49, the first 3 at 846. - Antti Karttunen, Sep 22 2017

Examples

			For n = 3, 3 itself is a squarefree number, thus a(3) = 0.
For n = 48, 48 = 2^4 * 3 is not squarefree, 49 = 7^2 is not squarefree, but 47 is, thus a(48) = abs(48-47) = 1.
For n = 49, neither 49 = 7^2, nor 48 = 2^4 * 3 nor 50 = 2^2 * 5 is squarefree, while both 47 and 51 are, thus a(49) = abs(49-47) = abs(49-51) = 2.
		

Crossrefs

Programs

  • Mathematica
    nn=110;With[{sqfr=Select[Range[nn+10],SquareFreeQ]},Flatten[Table[ Union[ Abs[ Nearest[ sqfr,n]-n]],{n,nn}]]] (* Harvey P. Dale, Jun 01 2012 *)
  • PARI
    A080733(n) = { my(k=0); while((!issquarefree(n+k))&&(!issquarefree(n-k)),k++); k; }; \\ Antti Karttunen, Sep 22 2017

Formula

a(A005117(n)) = 0.

Extensions

Examples added by Antti Karttunen, Sep 22 2017

A051701 Closest prime to n-th prime p that is different from p (break ties by taking the smaller prime).

Original entry on oeis.org

3, 2, 3, 5, 13, 11, 19, 17, 19, 31, 29, 41, 43, 41, 43, 47, 61, 59, 71, 73, 71, 83, 79, 83, 101, 103, 101, 109, 107, 109, 131, 127, 139, 137, 151, 149, 151, 167, 163, 167, 181, 179, 193, 191, 199, 197, 199, 227, 229, 227, 229, 241, 239, 257, 251, 257, 271, 269
Offset: 1

Views

Author

Keywords

Comments

A227878 gives the terms occurring twice. - Reinhard Zumkeller, Oct 25 2013

Examples

			Closest primes to 2,3,5,7,11 are 3,2,3,5,13.
		

Crossrefs

Programs

  • Haskell
    a051701 n = a051701_list !! (n-1)
    a051701_list = f 2 $ 1 : a000040_list where
       f d (q:ps@(p:p':_)) = (if d <= d' then q else p') : f d' ps
         where d' = p' - p
    -- Reinhard Zumkeller, Oct 25 2013
    
  • Mathematica
    a[n_] := (p = Prime[n]; np = NextPrime[p]; pp = NextPrime[p, -1]; If[np-p < p-pp, np, pp]); Table[a[n], {n, 1, 58}] (* Jean-François Alcover, Oct 20 2011 *)
    cp[{a_,b_,c_}]:=If[c-bHarvey P. Dale, Oct 08 2012 *)
  • Python
    from sympy import nextprime
    def aupton(terms):
      prv, cur, nxt, alst = 0, 2, 3, []
      while len(alst) < terms:
        alst.append(prv if 2*cur - prv <= nxt else nxt)
        prv, cur, nxt = cur, nxt, nextprime(nxt)
      return alst
    print(aupton(58)) # Michael S. Branicky, Jun 04 2021

Extensions

More terms from James Sellers

A080732 Smallest distance from n to a prime power (as defined in A246655).

Original entry on oeis.org

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

Views

Author

Benoit Cloitre, Mar 08 2003

Keywords

Comments

a(n)=min (abs(n-k) : where k runs through the prime powers)

Crossrefs

There are four different sequences which may legitimately be called "prime powers": A000961 (p^k, k >= 0), A246655 (p^k, k >= 1), A246547 (p^k, k >= 2), A025475 (p^k, k=0 and k >= 2). When you refer to "prime powers", be sure to specify which of these you mean. - N. J. A. Sloane, Mar 24 2018

Programs

  • Mathematica
    nn = 100; pp = Select[Range[2, Prime[1 + PrimePi[nn]]], Length[FactorInteger[#]] == 1 &]; Table[Min[Abs[n - pp]], {n, nn}] (* T. D. Noe, Mar 14 2012 *)
Showing 1-10 of 27 results. Next