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 10 results.

A018252 The nonprime numbers: 1 together with the composite numbers, A002808.

Original entry on oeis.org

1, 4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30, 32, 33, 34, 35, 36, 38, 39, 40, 42, 44, 45, 46, 48, 49, 50, 51, 52, 54, 55, 56, 57, 58, 60, 62, 63, 64, 65, 66, 68, 69, 70, 72, 74, 75, 76, 77, 78, 80, 81, 82, 84, 85, 86, 87, 88
Offset: 1

Views

Author

Keywords

Comments

d(a(n)) != 2 (cf. A000005). - Juri-Stepan Gerasimov, Oct 17 2009
Number of prime divisors of a(n) (counted with multiplicity) != 1. - Juri-Stepan Gerasimov, Oct 30 2009
Largest nonprime < n-th composite. - Juri-Stepan Gerasimov, Oct 29 2009
The nonnegative nonprimes A141468 without zero; the natural nonprimes; the whole nonprimes; the counting nonprimes. If the nonprime numbers A141468 which are also the nonnegative integers A001477, then the nonprimes A141468 also called the nonnegative nonprimes. If the nonprime numbers A018252 which are also the natural (or whole or counting) numbers A000027, then the nonprimes A018252 also called the natural nonprimes, the whole nonprimes and the counting nonprimes. - Juri-Stepan Gerasimov, Nov 22 2009
Smallest nonprime > n-th nonnegative nonprime. - Juri-Stepan Gerasimov, Dec 04 2009
a(n) = A175944(A014284(n)) = A175944(A175965(n)). - Reinhard Zumkeller, Mar 18 2011

References

  • G. H. Hardy and E. M. Wright, An Introduction to the Theory of Numbers. 3rd ed., Oxford Univ. Press, 1954, p. 2.

Crossrefs

Cf. A000040 (complement), A002808.
Boustrophedon transforms: A230955, A230954.

Programs

  • GAP
    A018252 := Difference([1..10^5], Filtered([1..10^5], IsPrime)); # Muniru A Asiru, Oct 21 2017
    
  • Haskell
    a018252 n = a018252_list !! (n-1)
    a018252_list = filter ((== 0) . a010051) [1..]
    -- Reinhard Zumkeller, Mar 31 2014
    
  • Magma
    [n : n in [1..100] | not IsPrime(n) ];
    
  • Maple
    with(numtheory); sort(convert(convert([ seq(i,i=1..541) ],set) minus convert([ seq(ithprime(i),i=1..100) ],set),list));
    seq(`if`(not isprime(n),n,NULL),n=1..88); # Peter Luschny, Jul 29 2009
    A018252 := proc(n) option remember; if n = 1 then 1; else for a from procname(n-1)+1 do if not isprime(a) then return a; end if; end do; end if; end proc: # R. J. Mathar, Oct 22 2010
  • Mathematica
    nonPrime[n_Integer] := FixedPoint[n + PrimePi@# &, n + PrimePi@ n]; Array[ nonPrime, 75] (* Robert G. Wilson v, Jan 29 2015, based on the algorithm by Labos Elemer in A006508 *)
    max = 90; Complement[Range[max], Prime[Range[PrimePi[max]]]] (* Harvey P. Dale, Aug 12 2011 *)
    Join[{1}, Select[Range[100], CompositeQ]] (* Jean-François Alcover, Nov 07 2021 *)
  • PARI
    isA018252(n) = !isprime(n)
    A018252(n) = {local(a,b);b=n;a=1;while(a!=b,a=b;b=n+primepi(a));b} \\ Michael B. Porter, Nov 06 2009
    
  • PARI
    a(n) = my(k=0); while(-n+n-=k-k=primepi(n), ); n; \\ Ruud H.G. van Tol, Jul 15 2024 (after code in A002808)
    
  • Python
    from sympy import isprime
    def ok(n): return not isprime(n)
    print([k for k in range(1, 89) if ok(k)]) # Michael S. Branicky, Nov 10 2022
    
  • Python
    from sympy import composite
    def A018252(n): return 1 if n == 1 else composite(n-1) # Chai Wah Wu, Nov 15 2022
  • Sage
    def A018252_list(n) :
        return [k for k in (1..n) if not k.is_prime()]
    A018252_list(88)  # Peter Luschny, Feb 03 2012
    

Formula

Let b(0) = n + pi(n) and b(n+1) = n + pi(b(n)), with pi(n) = A000720(n); then a(n) is the limit value of b(n). - Floor van Lamoen, Oct 08 2001
a(n) = A137621(A137624(n)). - Reinhard Zumkeller, Jan 30 2008
A010051(a(n)) = 0. - Reinhard Zumkeller, Mar 31 2014
A239968(a(n)) = n. - Reinhard Zumkeller, Dec 02 2014

A005171 Characteristic function of nonprimes: 0 if n is prime, else 1.

Original entry on oeis.org

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

Views

Author

Keywords

Comments

Number of orbits of length n in map whose periodic points are A023890. - Thomas Ward
Characteristic function of nonprimes A018252. - Jonathan Vos Post, Dec 30 2007
Triangle A157423 = A005171 in every column. A052284 = INVERT transform of A005171, and the eigensequence of triangle A157423. - Gary W. Adamson, Feb 28 2009

References

  • Douglas Hofstadter, Fluid Concepts and Creative Analogies: Computer Models of the Fundamental Mechanisms of Thought.

Crossrefs

Programs

  • Haskell
    a005171 = (1 -) . a010051  -- Reinhard Zumkeller, Mar 30 2014
    
  • Maple
    A005171 := proc(n)
        if isprime(n) then
            0 ;
        else
            1 ;
        end if;
    end proc: # R. J. Mathar, May 26 2017
  • Mathematica
    a[n_] := If[PrimeQ@ n, 0, 1]; Array[a, 105] (* Robert G. Wilson v, Jun 20 2011 *)
    nn = 105; t[n_, k_] :=  t[n, k] = If[n == k, 1, If[k == 1, 1 - Product[t[n, k + i], {i, 1, n - 1}], If[Mod[n, k] == 0, t[n/k, 1], 1], 1]]; Table[t[n, 1], {n, 1, nn}] (* Mats Granvik, Sep 21 2013 *)
  • PARI
    a(n)=if(n<1, 0, !isprime(n)) /* Michael Somos, Jun 08 2005 */
    
  • Python
    from sympy import isprime
    def a(n): return int(not isprime(n))
    print([a(n) for n in range(1, 106)]) # Michael S. Branicky, Oct 28 2021

Formula

a(n) = (1/n)* Sum_{ d divides n } mu(d)*A023890(n/d). E.g., a(6) = 1 since the 6th term of A023890 is 7 and the first term is 1. [edited by Michel Marcus, Dec 14 2023]
a(n) = 1 - A010051(n). - Jonathan Vos Post, Dec 30 2007
a(n) equals the first column in a table T defined by the recurrence: If n = k then T(n,k) = 1 else if k = 1 then T(n,k) = 1 - Product_{k divides n} of T(n,k), else if k divides n then T(n,k) = T(n/k,1). This is true since T(n,k) = 0 when k divides n and n/k is prime which results in Product_{k divides n} = 0 for the composite numbers and where k ranges from 2 to n. Therefore there is a remaining 1 in the expression 1-Product_{k divides n}, in the first column. Provided below is a Mathematica program as an illustration. - Mats Granvik, Sep 21 2013
a(n) = A057427(A239968(n)). - Reinhard Zumkeller, Mar 30 2014
a(n) = Sum_{d|n} A033273(d)*A008683(n/d). - Ridouane Oudra, Jul 03 2025

A305800 Filter sequence for a(prime) = constant sequences.

Original entry on oeis.org

1, 2, 2, 3, 2, 4, 2, 5, 6, 7, 2, 8, 2, 9, 10, 11, 2, 12, 2, 13, 14, 15, 2, 16, 17, 18, 19, 20, 2, 21, 2, 22, 23, 24, 25, 26, 2, 27, 28, 29, 2, 30, 2, 31, 32, 33, 2, 34, 35, 36, 37, 38, 2, 39, 40, 41, 42, 43, 2, 44, 2, 45, 46, 47, 48, 49, 2, 50, 51, 52, 2, 53, 2, 54, 55, 56, 57, 58, 2, 59, 60, 61, 2, 62, 63, 64, 65, 66, 2, 67, 68, 69, 70, 71, 72, 73, 2, 74, 75, 76, 2, 77, 2, 78, 79, 80, 2, 81, 2, 82, 83, 84, 2, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96
Offset: 1

Views

Author

Antti Karttunen, Jun 14 2018

Keywords

Comments

Restricted growth sequence transform of A239968.
In the following, A stands for this sequence, A305800, and S -> T (where S and T are sequence A-numbers) indicates that for all i, j: S(i) = S(i) => T(i) = T(j).
For example, the following implications hold:
A -> A300247 -> A305897 -> A077462 -> A101296,
A -> A290110 -> A300250 -> A101296.

Crossrefs

Differs from A296073 for the first time at n=125, as a(125) = 96, while A296073(125) = 33.
Cf. also A305900, A305801, A295300, A289626 for other "upper level" filters.

Programs

  • Mathematica
    Join[{1},Table[If[PrimeQ[n],2,1+n-PrimePi[n]],{n,2,150}]] (* Harvey P. Dale, Jul 12 2019 *)
  • PARI
    A305800(n) = if(1==n,n,if(isprime(n),2,1+n-primepi(n)));

Formula

a(1) = 1; for n > 1, a(n) = 2 for prime n, and a(n) = 1+n-A000720(n) for composite n.

A066246 a(n) = 0 unless n is a composite number A002808(k) then a(n) = k.

Original entry on oeis.org

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

Views

Author

Reinhard Zumkeller, Dec 09 2001

Keywords

Crossrefs

Programs

  • Haskell
    import Data.List (unfoldr, genericIndex)
    a066246 n = genericIndex a066246_list (n - 1)
    a066246_list = unfoldr x (1, 1, a002808_list) where
       x (i, z, cs'@(c:cs)) | i == c = Just (z, (i + 1, z + 1, cs))
                            | i /= c = Just (0, (i + 1, z, cs'))
    -- Reinhard Zumkeller, Jan 29 2014
  • Mathematica
    Module[{k=1},Table[If[CompositeQ[n],k;k++,0],{n,100}]] (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, Jan 03 2019 *)
  • PARI
    a(n)=if(isprime(n),0,max(0,n-primepi(n)-1)) \\ Charles R Greathouse IV, Aug 21 2011
    

Formula

a(n) = A239968(n) + A010051(n) - 1. - Reinhard Zumkeller, Mar 30 2014
a(n) = A065855(n)*A005171(n). - Ridouane Oudra, Jul 29 2025

A026233 a(n) = j if n is the j-th prime, else a(n) = k if n is the k-th nonprime.

Original entry on oeis.org

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

Views

Author

Keywords

Comments

Each n occurs at two positions, the distances between them are: 1, 1, 1, 1, 2, 3, 5, 5, 8, 13, 13, 17, 20, 21, 23, 28, 33, 34, 39, 41, 41, ... - Zak Seidov, Mar 06 2011

Crossrefs

Cf. A026238.

Programs

  • Haskell
    a026233 n = a049084 n + a239968 n
    -- Reinhard Zumkeller, Mar 30 2014, Feb 12 2014
    
  • Mathematica
    m=100;pr=Prime[Range[m]];npr=Select[Range[m],!PrimeQ[#]&];
    a[n_]:=If[PrimeQ[n],PrimePi[n],Position[npr,n][[1,1]]]; Table[a[n],{n,m}] (* Zak Seidov Mar 05 2011 *) s=Range[500];Do[s=Insert[s,n,Prime[n]],{n,100}];s (* Zak Seidov, Mar 05 2011 *)
  • PARI
    first(n)=my(p,c); vector(n,k,if(isprime(k),p++,c++)) \\ Charles R Greathouse IV, Sep 02 2015

Formula

a(n) = A049084(n) + A066246(n) + A000007(A010051(n)). - Reinhard Zumkeller, Feb 12 2014
a(n) = A049084(n) + A239968(n). - Reinhard Zumkeller, Mar 30 2014

A026238 a(n) = j if n is the j-th prime, else a(n) = k if n is the k-th composite.

Original entry on oeis.org

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

Views

Author

Keywords

Crossrefs

Programs

  • Haskell
    a026238 n = a049084 n + a066246 n  -- Reinhard Zumkeller, Jan 29 2014
    
  • Mathematica
    Table[If[PrimeQ[n],PrimePi[n],n-1-PrimePi[n]],{n,2,70}] (* Harvey P. Dale, Jun 06 2017 *)
  • PARI
    first(n)=my(c,p); vector(n-1,k, if(isprime(k+1),p++,c++)) \\ Charles R Greathouse IV, Sep 02 2015

Formula

a(n) = A049084(n) + A066246(n) for n >= 2.

A296073 Filter combining A296071(n) and A296072(n), related to the deficiencies of proper divisors of n.

Original entry on oeis.org

1, 2, 2, 3, 2, 4, 2, 5, 6, 7, 2, 8, 2, 9, 10, 11, 2, 12, 2, 13, 14, 15, 2, 16, 17, 18, 19, 20, 2, 21, 2, 22, 23, 24, 25, 26, 2, 27, 28, 29, 2, 30, 2, 31, 32, 33, 2, 34, 35, 36, 37, 38, 2, 39, 40, 41, 42, 43, 2, 44, 2, 45, 46, 47, 48, 49, 2, 50, 51, 52, 2, 53, 2, 54, 55, 56, 57, 58, 2, 59, 60, 61, 2, 62, 63, 64, 65, 66, 2, 67, 68, 69, 70, 71, 72, 73, 2, 74, 75, 76, 2, 77, 2, 78, 79, 80, 2, 81, 2, 82, 83, 84, 2, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 33
Offset: 1

Views

Author

Antti Karttunen, Dec 04 2017

Keywords

Comments

Construction: Pack the values of A296071(n) and A296072(n) to a single value with any injective N x N -> N packing function, like for example as f(n) = (1/2)*(2 + ((A296071(n)+A296072(n))^2) - A296071(n) - 3*A296072(n)) (the packing function here is the two-argument form of A000027). Then apply the restricted growth sequence transform to the sequence f(1), f(2), f(3), ... The transform assigns a unique increasing number for each newly encountered term of the sequence, and for any subsequent occurrences of the same term it gives the same number that term obtained for the first time.
For all i, j: a(i) = a(j) => A296074(i) = A296074(j).
Note that this is NOT restricted growth transform of A239968, which is A305800. Apart from 2's that occur at every prime, there are other duplicates also, first at a(125) = a(46) = 33.

Examples

			To see that a(46) and a(125) have the same value (33), consider the proper divisors of 46 = 1, 2, 23 and of 125 = 1, 5, 25. Their deficiencies are 1, 1, 22 and 1, 4, 19 respectively. When we look at their balanced ternary representations [as here all elements are positive, it can be obtained as A007089(A117967(n)) with 2's standing for -1's]:
   1 =    1
   1 =    1
  22 = 1211 (as 22 = 1*(3^3) + -1*(3^2) + 1*(3^1) + 1*(3^0))
and
   1 =    1
   4 =   11
  19 = 1201 (as 19 = 1*(3^3) + -1*(3^2) + 0*(3^1) + 1*(3^0)).
we see that in each column there is an equal number of 1's and an equal number of 2's. Moreover, this then implies also that the sums of those two sequences of deficiencies {1, 1, 22} and {1, 4, 19} are equal, as A296074(n) is a function of (can be computed from) a(n).
		

Crossrefs

Cf. also A293226.
Differs from A305800 for the first time at n=125.

Programs

  • PARI
    up_to = 65536;
    rgs_transform(invec) = { my(om = Map(), outvec = vector(length(invec)), u=1); for(i=1, length(invec), if(mapisdefined(om,invec[i]), my(pp = mapget(om, invec[i])); outvec[i] = outvec[pp] , mapput(om,invec[i],i); outvec[i] = u; u++ )); outvec; };
    write_to_bfile(start_offset,vec,bfilename) = { for(n=1, length(vec), write(bfilename, (n+start_offset)-1, " ", vec[n])); }
    A019565(n) = {my(j,v); factorback(Mat(vector(if(n, #n=vecextract(binary(n), "-1..1")), j, [prime(j), n[j]])~))}; \\ This function from M. F. Hasler
    A117967(n) = if(n<=1,n,if(!(n%3),3*A117967(n/3),if(1==(n%3),1+3*A117967((n-1)/3),2+3*A117967((n+1)/3))));
    A117968(n) = if(1==n,2,if(!(n%3),3*A117968(n/3),if(1==(n%3),2+3*A117968((n-1)/3),1+3*A117968((n+1)/3))));
    A289813(n) = { my (d=digits(n, 3)); from digits(vector(#d, i, if (d[i]==1, 1, 0)), 2); } \\ From Rémy Sigrist
    A289814(n) = { my (d=digits(n, 3)); from digits(vector(#d, i, if (d[i]==2, 1, 0)), 2); } \\ From Rémy Sigrist
    A295882(n) = { my(x = (2*n)-sigma(n)); if(x >= 0,A117967(x),A117968(-x)); };
    A296071(n) = { my(m=1); fordiv(n,d,if(d < n,m *= A019565(A289813(A295882(d))))); m; };
    A296072(n) = { my(m=1); fordiv(n,d,if(d < n,m *= A019565(A289814(A295882(d))))); m; };
    Anotsubmitted3(n) = (1/2)*(2 + ((A296071(n)+A296072(n))^2) - A296071(n) - 3*A296072(n));
    write_to_bfile(1,rgs_transform(vector(up_to,n,Anotsubmitted3(n))),"b296073.txt");

Extensions

Data section extended up to a(125) by Antti Karttunen, Jun 14 2018

A249594 Positions of primes in A249054.

Original entry on oeis.org

2, 4, 7, 11, 12, 14, 17, 18, 19, 22, 23, 27, 30, 32, 34, 37, 38, 41, 42, 45, 47, 50, 51, 53, 54, 55, 58, 61, 64, 65, 68, 71, 72, 74, 75, 78, 80, 81, 84, 87, 89, 90, 94, 97, 100, 102, 105, 108, 109, 111, 113, 116, 117, 119, 120, 123, 125, 129, 133, 134, 135
Offset: 1

Views

Author

Reinhard Zumkeller, Nov 03 2014

Keywords

Comments

A249054(a(n)) = A000040(n); sequence is strictly increasing, i.e. all primes occur in A249054 in natural order, see also A249595.

Crossrefs

Cf. A000040, A026233, A049084, A239968, A249054, A249595 (complement).

Programs

  • Haskell
    import Data.List (elemIndex); import Data.Maybe (fromJust)
    a249594 = (+ 1) . fromJust . (`elemIndex` a249054_list) . a000040

A249595 Positions of nonprimes in A249054.

Original entry on oeis.org

1, 3, 5, 6, 8, 9, 10, 13, 15, 16, 20, 21, 24, 25, 26, 28, 29, 31, 33, 35, 36, 39, 40, 43, 44, 46, 48, 49, 52, 56, 57, 59, 60, 62, 63, 66, 67, 69, 70, 73, 76, 77, 79, 82, 83, 85, 86, 88, 91, 92, 93, 95, 96, 98, 99, 101, 103, 104, 106, 107, 110, 112, 114, 115
Offset: 1

Views

Author

Reinhard Zumkeller, Nov 03 2014

Keywords

Comments

A249054(a(n)) = A018252(n); sequence is strictly increasing, i.e. all nonprimes occur in A249054 in natural order, see also A249594.

Crossrefs

Cf. A018252, A026233, A049084, A239968, A249054, A249594 (complement).

Programs

  • Haskell
    import Data.List (elemIndex); import Data.Maybe (fromJust)
    a249595 = (+ 1) . fromJust . (`elemIndex` a249054_list) . a018252

A251392 Indices of nonprimes in A098550.

Original entry on oeis.org

1, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20, 21, 24, 25, 26, 27, 28, 29, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 44, 45, 46, 47, 48, 49, 50, 52, 53, 54, 55, 56, 57, 58, 59, 60, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77
Offset: 1

Views

Author

Reinhard Zumkeller, Dec 03 2014

Keywords

Comments

A010051(A098550(a(n))) = 0; A239968(A098550(a(n))) > 0;
three equivalent statements:
1) A098550 is a permutation of the positive integers, cf. A000027;
2) A251392 is a permutation of the nonprimes, cf. A018252;
3) A251392 is the complement of A251239.

Crossrefs

Cf. A098550, A018252, A010051, A239968, A251239, A251240 (subsequence).

Programs

  • Haskell
    a251392 n = a251392_list !! (n-1)
    a251392_list = filter ((== 0) . a010051' . a098550) [1..]
Showing 1-10 of 10 results.