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.

A118777 a(0) = 1; n > 0: a(n) = a(n-1) + d, d = +-1 if n is prime/nonprime.

Original entry on oeis.org

1, 2, 1, 0, 1, 0, 1, 0, 1, 2, 3, 2, 3, 2, 3, 4, 5, 4, 5, 4, 5, 6, 7, 6, 7, 8, 9, 10, 11, 10, 11, 10, 11, 12, 13, 14, 15, 14, 15, 16, 17, 16, 17, 16, 17, 18, 19, 18, 19, 20, 21, 22, 23, 22, 23, 24, 25, 26, 27, 26, 27, 26, 27, 28, 29, 30, 31, 30, 31, 32, 33, 32, 33, 32, 33, 34, 35, 36
Offset: 0

Views

Author

Zak Seidov, May 22 2006

Keywords

Crossrefs

One more than A097454, two more than A072731.
For no apparent reason, the terms a(3)..a(24) are equal to the terms a(0)..a(21) of A276090.

Programs

  • Mathematica
     Table[n + 1 - 2*PrimePi[n], {n, 0, 100}]
  • Scheme
    ;; With memoization-macro definec.
    (definec (A118777 n) (if (zero? n) 1 (+ (A118777 (- n 1)) (expt -1 (A010051 n)))))
    ;; Antti Karttunen, Aug 19 2016
    
  • Scheme
    (define (A118777 n) (+ 1 (- n (* 2 (A000720 n))))) ;; After formula given by the original author.
    ;; Antti Karttunen, Aug 19 2016

Formula

a(n) = n + 1 - 2*primepi(n), n = 0, 1, 2, ..., where primepi(n) = A000720(n).
From Antti Karttunen, Aug 21 2016: (Start)
a(0) = 1, for n >= 1, a(n) = a(n-1) + (-1)^A010051(n). (from the definition).
For all n >= 1, a(n) = 1+A097454(n) = 2+A072731(n).
(End)

Extensions

Offset and the name corrected by Antti Karttunen, Aug 19 2016

A383037 a(n) is the excess of composites over primes in the first n odd positive integers.

Original entry on oeis.org

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

Views

Author

Felix Huber, Apr 19 2025

Keywords

Examples

			Of the first 5 odd positive integers (1, 3, 5, 7, 9), one (9) is a composite and three (3, 5, 7) are primes, so a(5) = 1 - 3 = -2.
		

Crossrefs

Programs

  • Maple
    A383037:=n->n-NumberTheory:-pi(2*n)*2+1;seq(A383037(n),n=1..71);
  • Mathematica
    a[n_]:=n - 2*PrimePi[2*n] + 1; Array[a,71] (* Stefano Spezia, Apr 20 2025 *)

Formula

a(n) = n - 2*pi(2*n) + 1.
a(n) = A210469(n) - pi(2*n) + 1 = A210469(n) - A000720(2*n) + 1 = for n > 1.
a(n) = A118777(2*n-1) - n + 1 for n > 1.
a(n) = A097454(2*n-1) - n + 2 for n > 1.
a(n) = A072731(2*n-1) - n + 3 for n > 1.

A243106 a(n) = Sum_{k=1..n} (-1)^isprime(k)*10^k.

Original entry on oeis.org

10, -90, -1090, 8910, -91090, 908910, -9091090, 90908910, 1090908910, 11090908910, -88909091090, 911090908910, -9088909091090, 90911090908910, 1090911090908910, 11090911090908910, -88909088909091090, 911090911090908910, -9088909088909091090
Offset: 1

Views

Author

R. J. Cano, Aug 19 2014

Keywords

Comments

Alternative definition: a(n,x)=T(x,1) for a dichromate or Tutte-Whitney polynomial in which the matrix t[i,j] is defined as t[i,j]=Delta(i,j)*((-1)^isprime(i)) and "Delta" is the Kronecker Delta function. - Michel Marcus, Aug 19 2014
If 10 is replaced by 1, then this becomes A097454. If it is replaced by 2, one gets A242002. Choosing powers of the base b=10, as done here, allows one to easily read off the equivalent for any other base b > 4, by simply replacing digits 8,9 with b-2,b-1 (when terms are written in base b). [Comment extended by M. F. Hasler, Aug 20 2014]
There are 2^n ways of taking the partial sum of the first n powers of b=10 if exponent zero is excluded and the signs can be assigned arbitrarily. Conjecture: When expressed in base b, the absolute value for any of these terms only contains digits belonging to {0,1,b-2,b-1}; here {0,1,8,9}.

Examples

			n=1 is not prime x^1 = (10)^1 = 10, therefore a(1)=10;
n=2 is prime and x^2 = (10)^2 = 100, taking it negative, a(2) = 10 - 100 = -90;
n=3 also is prime, x^3 = 1000, and we have a(3) = 10 - 100 - 1000 = -1090;
n=4 is not prime, so a(4) = 10 - 100 - 1000 + 10000 = 8910;
n=5 is prime, then a(5) = 10 - 100 - 1000 + 10000 - 100000 = -91090;
Examples of analysis for the concatenation patterns among the terms can be found at the "Additional Information" link.
		

Crossrefs

Cf. A097454.
The same kind of base-independent behavior: A215940, A217626.
Partial sums of alternating series: A181482, A222739, A213203.

Programs

  • Mathematica
    Table[Sum[ (-1)^Boole@ PrimeQ@ k*10^k, {k, n}], {n, 19}] (* Michael De Vlieger, Jan 03 2016 *)
  • PARI
    ap(n, x)={my(s); forprime(p=1, n, s+=x^p); s}
    a=(n, x=10)->(x^(n+1)-1)/(x-1)-2*ap(n, x)-1;
    
  • PARI
    Delta=(i, j)->(i==j); /* Kronecker's Delta function */
    t=n->matrix(n, n, i, j, Delta(i, j)*((-1)^isprime(i))); /* coeffs t[i, j] */
    /* Tutte polynomial over n */
    T(n, x, y)={my(t0=t(n)); sum(i=1, n, sum(j=1, n, t0[i, j]*(x^i)*(y^j)))};
    a=(n, x=10)->T(n, x, 1);
    
  • PARI
    A243106(n,b=10)=sum(k=1,n,(-1)^isprime(k)*b^k) \\ M. F. Hasler, Aug 20 2014

Formula

a(n,x) = Sum_{k=1..n} (-1)^isprime(k)*(x^k), for x=10 in decimal.

Extensions

Definition simplified by N. J. A. Sloane, Aug 19 2014
Definition further simplified and more terms from M. F. Hasler, Aug 20 2014

A116568 Difference between n and the absolute value of the difference between number of nonprimes not exceeding n and number of primes not exceeding n.

Original entry on oeis.org

0, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 10, 12, 12, 12, 12, 14, 14, 16, 16, 16, 16, 18, 18, 18, 18, 18, 18, 20, 20, 22, 22, 22, 22, 22, 22, 24, 24, 24, 24, 26, 26, 28, 28, 28, 28, 30, 30, 30, 30, 30, 30, 32, 32, 32, 32, 32, 32, 34, 34, 36, 36, 36, 36, 36, 36, 38, 38, 38, 38, 40, 40, 42
Offset: 1

Views

Author

Roger L. Bagula, Mar 18 2006

Keywords

Examples

			a(11)=10 because the nonprimes not exceeding 11 are 1,4,6,8,9 and 10, the primes not exceeding 11 are 2,3,5,7 and 11 and 11-abs(6-5)=10.
		

Crossrefs

Cf. A097454.

Programs

  • Maple
    with(numtheory): seq(n-abs(n-2*pi(n)),n=1..73);
  • Mathematica
    Table[n-Abs[2*PrimePi[n]-n],{n,80}] (* Harvey P. Dale, Oct 08 2015 *)
  • PARI
    for(n=1,50, print1(n - abs(2*primepi(n) - n) , ", ")) \\ G. C. Greubel, Sep 20 2017

Formula

a(n) = n - Abs[A097454(n)].

Extensions

Edited by N. J. A. Sloane, Apr 05 2006

A361915 a(n) is the smallest prime p such that, for m >= nextprime(p), there are more composites than primes in the range [2, m], where multiples of primes prime(1) through prime(n) are excluded.

Original entry on oeis.org

13, 113, 1069, 5051, 18553, 44417, 99439, 190921, 356351, 603149, 933073, 1416223, 2044201, 2856559, 3957883, 5379287, 7093217, 9113263, 11693687, 14701529, 18345209, 22758829, 27879563, 33938257, 40808759, 48364003, 57099061, 67292237, 78919781, 92417891
Offset: 0

Views

Author

Ya-Ping Lu, Mar 29 2023

Keywords

Examples

			The number of primes, N_p, and the number of composite, N_c, in the range [2, m] are listed in the table below, where N_p = N_c occurs at m = 9, 11 and 13. For m >= nextprime(13) = 17, N_c > N_p. So, a(0) = 13 is the case for n = 0, in which none of the multiples of primes is excluded from the integer list.
   m:   2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, ...
   N_p: 1, 2, 2, 3, 3, 4, 4, 4,  4,  5,  5,  6,  6,  6,  6,  7, ...
   N_c: 0, 0, 1, 1, 2, 2, 3, 4,  5,  5,  6,  6,  7,  8,  9,  9, ...
If the multiples of prime(1) are excluded from the list, 113 is the smallest prime such that N_c > N_p for m >= nextprime(113) = 127 and, thus, a(1) = 113 (see below).
   m:   3, 5, 7, ..., 93, 95, 97, 99, 101, 103, 105, 107, 109, 111, 113, 115, ...
   N_p: 1, 2, 3, ..., 23, 23, 24, 24,  25,  26,  26,  27,  28,  28,  29,  29, ...
   N_c: 0, 0, 0, ..., 23, 24, 24, 25,  25,  25,  26,  26,  26,  27,  27,  28, ...
If multiples of prime(1) and prime(2) are excluded, a(2) = 1069. If multiples of prime(1), prime(2) and prime(3) are excluded, a(3) = 5051.
		

Crossrefs

Programs

  • Python
    from sympy import isprime, prime
    R = []; L = [x for x in range(2, 100000001)]
    for n in range(30):
        np = 0; nc = 0; found = 0
        if n > 0: q = prime(n); L = [x for x in L if x%q != 0]
        for m in L:
            if isprime(m): np += 1; p = m
            else: nc += 1
            if np == nc: Lp = p; found = 1
        if found: R.append(Lp)
    print(*R, sep = ", ")
Showing 1-5 of 5 results.