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

A066248 a(n) = if n+1 is prime then A049084(n+1)*2 else A066246(n+1)*2 - 1.

Original entry on oeis.org

2, 4, 1, 6, 3, 8, 5, 7, 9, 10, 11, 12, 13, 15, 17, 14, 19, 16, 21, 23, 25, 18, 27, 29, 31, 33, 35, 20, 37, 22, 39, 41, 43, 45, 47, 24, 49, 51, 53, 26, 55, 28, 57, 59, 61, 30, 63, 65, 67, 69, 71, 32, 73, 75, 77, 79, 81, 34, 83, 36, 85, 87, 89, 91, 93, 38, 95, 97, 99, 40, 101, 42
Offset: 1

Views

Author

Reinhard Zumkeller, Dec 09 2001

Keywords

Comments

Permutation of natural numbers; inverse: A066249.

Crossrefs

Programs

  • Mathematica
    a[n_] := If[PrimeQ[n+1], 2 * PrimePi[n+1], 2 * (n - PrimePi[n+1]) - 1]; Array[a, 100] (* Amiram Eldar, Mar 19 2025 *)

Formula

a(n) = A026238(n+1)*2 - A066247(n+1).

A066250 a(n) = if n+1 is prime then A049084(n+1)*2 - 1 else A066246(n+1)*2.

Original entry on oeis.org

1, 3, 2, 5, 4, 7, 6, 8, 10, 9, 12, 11, 14, 16, 18, 13, 20, 15, 22, 24, 26, 17, 28, 30, 32, 34, 36, 19, 38, 21, 40, 42, 44, 46, 48, 23, 50, 52, 54, 25, 56, 27, 58, 60, 62, 29, 64, 66, 68, 70, 72, 31, 74, 76, 78, 80, 82, 33, 84, 35, 86, 88, 90, 92, 94, 37, 96, 98, 100, 39, 102
Offset: 1

Views

Author

Reinhard Zumkeller, Dec 09 2001

Keywords

Comments

Permutation of natural numbers; inverse: A066251.

Crossrefs

Formula

a(n) = A026238(n+1)*2 - A010051(n+1).

A135141 a(1)=1, a(p_n)=2*a(n), a(c_n)=2*a(n)+1, where p_n = n-th prime, c_n = n-th composite number.

Original entry on oeis.org

1, 2, 4, 3, 8, 5, 6, 9, 7, 17, 16, 11, 10, 13, 19, 15, 12, 35, 18, 33, 23, 21, 14, 27, 39, 31, 25, 71, 34, 37, 32, 67, 47, 43, 29, 55, 22, 79, 63, 51, 20, 143, 26, 69, 75, 65, 38, 135, 95, 87, 59, 111, 30, 45, 159, 127, 103, 41, 24, 287, 70, 53, 139, 151, 131, 77, 36, 271, 191
Offset: 1

Views

Author

Katarzyna Matylla, Feb 13 2008

Keywords

Comments

A permutation of the positive integers, related to A078442.
a(p) is even when p is prime and is divisible by 2^(prime order of p).
From Robert G. Wilson v, Feb 16 2008: (Start)
What is the length of the cycle containing 10? Is it infinite? The cycle begins 10, 17, 12, 11, 16, 15, 19, 18, 35, 29, 34, 43, 26, 31, 32, 67, 36, 55, 159, 1055, 441, 563, 100, 447, 7935, 274726911, 1013992070762272391167, ... Implementation in Mmca: NestList[a(AT)# &, 10, 26] Furthermore, it appears that any non-single-digit number has an infinite cycle.
Records: 1, 2, 4, 8, 9, 17, 19, 35, 39, 71, 79, 143, 159, 287, 319, 575, 639, 1151, 1279, 2303, 2559, 4607, 5119, 9215, 10239, 18431, 20479, 36863, 40959, 73727, 81919, 147455, 163839, 294911, 327679, 589823, 655359, ..., . (End)

Examples

			a(20) = 33 = 2*16 + 1 because 20 is 11th composite and a(11)=16. Or, a(20)=33=100001(bin). In other words it is a composite number, its index is a prime number, whose index is a prime....
		

Crossrefs

Cf. A246346, A246347 (record positions and values).
Cf. A227413 (inverse).
Cf. A071574, A245701, A245702, A245703, A245704, A246377, A236854, A237427 for related and similar permutations.

Programs

  • Haskell
    import Data.List (genericIndex)
    a135141 n = genericIndex a135141_list (n-1)
    a135141_list = 1 : map f [2..] where
       f x | iprime == 0 = 2 * (a135141 $ a066246 x) + 1
           | otherwise   = 2 * (a135141 iprime)
           where iprime = a049084 x
    -- Reinhard Zumkeller, Jan 29 2014
    
  • Mathematica
    a[1] = 1; a[n_] := If[PrimeQ@n, 2*a[PrimePi[n]], 2*a[n - 1 - PrimePi@n] + 1]; Array[a, 69] (* Robert G. Wilson v, Feb 16 2008 *)
  • Maxima
    /* Let pc = prime count (which prime it is), cc = composite count: */
    pc[1]:0;
    cc[1]:0;
    pc[2]:1;
    cc[4]:1;
    pc[n]:=if primep(n) then 1+pc[prev_prime(n)] else 0;
    cc[n]:=if primep(n) then 0 else if primep(n-1) then 1+cc[n-2] else 1+cc[n-1];
    a[1]:1;
    a[n]:=if primep(n) then 2*a[pc[n]] else 1+2*a[cc[n]];
    
  • PARI
    A135141(n) = if(1==n, 1, if(isprime(n), 2*A135141(primepi(n)), 1+(2*A135141(n-primepi(n)-1)))); \\ Antti Karttunen, Dec 09 2019
  • Python
    from sympy import isprime, primepi
    def a(n): return 1 if n==1 else 2*a(primepi(n)) if isprime(n) else 2*a(n - 1 - primepi(n)) + 1 # Indranil Ghosh, Jun 11 2017, after Mathematica code
    

Formula

a(n) = 2*A135141((A049084(n))*chip + A066246(n)*(1-chip)) + 1 - chip, where chip = A010051(n). - Reinhard Zumkeller, Jan 29 2014
From Antti Karttunen, Dec 09 2019: (Start)
A007814(a(n)) = A078442(n).
A070939(a(n)) = A246348(n).
A080791(a(n)) = A246370(n).
A054429(a(n)) = A246377(n).
A245702(a(n)) = A245703(n).
a(A245704(n)) = A245701(n). (End)

A066247 Characteristic function of composite numbers: 1 if n is composite else 0.

Original entry on oeis.org

0, 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

Reinhard Zumkeller, Dec 09 2001

Keywords

Comments

a(n) = signum(A066246(n)), where signum = A057427. For n > 1: a(n) = 1 - A010051(n) = A005171(n).
a(n) = A057427(A086971(n)). - Reinhard Zumkeller, Dec 14 2012

Crossrefs

Cf. A065855 (partial sums).

Programs

Formula

For n>1 a(n) = 1-floor(1/A001222(n)). - Enrique Pérez Herrero, Aug 08 2012
a(n) = A065855(n)-A065855(n-1) = 1-A000720(n)+A000720(n-1). - Chayim Lowen, Jul 23 2015
Dirichlet g.f.: Sum_{n>=1} a(n)/n^s = Zeta(s)-1-P(s), where P is prime zeta. - Enrique Pérez Herrero, Aug 08 2012
a(n) = 1 if A001222(n) > 1, 0 otherwise. - Antti Karttunen, Nov 20 2017

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

A239968 a(n) = 0 unless n is a nonprime A018252(k) then a(n) = k.

Original entry on oeis.org

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

Views

Author

Reinhard Zumkeller, Mar 30 2014

Keywords

Crossrefs

Programs

  • Haskell
    import Data.List (unfoldr, genericIndex)
    a239968 n = genericIndex a239968_list (n - 1)
    a239968_list = unfoldr c (1, 1, a018252_list) where
       c (i, z, xs'@(x:xs)) | i == x = Just (z, (i + 1, z + 1, xs))
                            | i /= x = Just (0, (i + 1, z, xs'))
  • Mathematica
    Module[{k = 0}, Array[If[!PrimeQ[#], ++k, 0] &, 100]] (* Paolo Xausa, Jul 31 2025 *)

Formula

a(n) = A066246(n) - A010051(n) + 1.
a(n) = A026233(n) - A049084(n);
A057427(a(n)) = A005171(n).
a(n) = A062298(n)*A005171(n). - Ridouane Oudra, Jul 29 2025

A071574 If n = k-th prime, a(n) = 2*a(k) + 1; if n = k-th nonprime, a(n) = 2*a(k).

Original entry on oeis.org

0, 1, 3, 2, 7, 6, 5, 4, 14, 12, 15, 10, 13, 8, 28, 24, 11, 30, 9, 20, 26, 16, 29, 56, 48, 22, 60, 18, 25, 40, 31, 52, 32, 58, 112, 96, 21, 44, 120, 36, 27, 50, 17, 80, 62, 104, 57, 64, 116, 224, 192, 42, 49, 88, 240, 72, 54, 100, 23, 34, 61, 160, 124, 208, 114, 128, 19
Offset: 1

Views

Author

Christopher Eltschka (celtschk(AT)web.de), May 31 2002

Keywords

Comments

The recursion start is implicit in the rule, since the rule demands that a(1)=2*a(1). All other terms are defined through terms for smaller indices until a(1) is reached.
a(n) is a bijective mapping from the positive integers to the nonnegative integers. Given the value of a(n), you can get back to n using the following algorithm:
Start with an initial value of k=1 and write a(n) in binary representation. Then for each bit, starting with the most significant one, do the following: - if the bit is 1, replace k by the k-th prime - if the bit is 0, replace k by the k-th nonprime. After you processed the last (i.e. least significant) bit of a(n), you've got n=k.
Example: From a(n) = 12 = 1100_2, you get 1->2->3=>6=>10; a(10)=12. Here each "->" is a step due to binary digit 1; each "=>" is a step due to binary digit 0.
The following sequences all appear to have the same parity (with an extra zero term at the start of A010051): A010051, A061007, A035026, A069754, A071574. - Jeremy Gardiner, Aug 09 2002. (At least with this sequence the identity a(n) = A010051(n) mod 2 is obvious, because each prime is mapped to an odd number and each composite to an even number. - Antti Karttunen, Apr 04 2015)
For n > 1: a(n) = 2 * a(if i > 0 then i else A066246(n) + 1) + A057427(i) with i = A049084(n). - Reinhard Zumkeller, Feb 12 2014
A237739(a(n)) = n; a(A237739(n)) = n. - Reinhard Zumkeller, Apr 30 2014

Examples

			1 is the 1st nonprime, so a(1) = 2*a(1), therefore a(1) = 0.
2 is the 1st prime, so a(2) = 2*a(1)+1 = 2*0+1 = 1.
4 is the 2nd nonprime, so a(4) = 2*a(2) = 2*1 = 2.
		

Crossrefs

Inverse: A237739.
Compare also to the permutation A246377.
Same parity: A010051, A061007, A035026, A069754.

Programs

  • Haskell
    a071574 1 = 0
    a071574 n = 2 * a071574 (if j > 0 then j + 1 else a049084 n) + 1 - signum j
                where j = a066246 n
    -- Reinhard Zumkeller, Feb 12 2014
    
  • Mathematica
    a[1]=0; a[n_]:=If[PrimeQ[n],2*a[PrimePi[n]]+1,2*a[n-PrimePi[n]]];Table[a[n],{n,100}]
  • PARI
    first(n) = my(res = vector(n), p); for(x=2, n, p=isprime(x); res[x]=2*res[x*!p-(-1)^p*primepi(x)]+p); res \\ Iain Fox, Oct 19 2018
  • Scheme
    ;; With memoizing definec-macro.
    (definec (A071574 n) (cond ((= 1 n) 0) ((= 1 (A010051 n)) (+ 1 (* 2 (A071574 (A000720 n))))) (else (* 2 (A071574 (+ 1 (A065855 n)))))))
    ;; Antti Karttunen, Apr 04 2015
    

Formula

a(1) = 0, and for n > 1, if A010051(n) = 1 [when n is a prime], a(n) = 1 + 2*a(A000720(n)), otherwise a(n) = 2*a(1 + A065855(n)). - Antti Karttunen, Apr 04 2015

Extensions

Mathematica program completed by Harvey P. Dale, Nov 28 2024

A026239 Beginning with the natural numbers, swap the k-th prime and k-th composite.

Original entry on oeis.org

1, 4, 6, 2, 8, 3, 9, 5, 7, 11, 10, 13, 12, 17, 19, 23, 14, 29, 15, 31, 37, 41, 16, 43, 47, 53, 59, 61, 18, 67, 20, 71, 73, 79, 83, 89, 21, 97, 101, 103, 22, 107, 24, 109, 113, 127, 25, 131, 137, 139, 149, 151, 26, 157, 163, 167, 173, 179, 27, 181, 28, 191, 193, 197, 199
Offset: 1

Views

Author

Keywords

Comments

Involution (self-inverse permutation) of [positive] natural numbers.

Crossrefs

Cf. A236854.

Programs

  • Haskell
    a026239 1 = 1
    a026239 n | a010051 n == 1 = a002808 $ a049084 n
              | otherwise      = a000040 $ a066246 n
    -- Reinhard Zumkeller, Mar 30 2014
  • Mathematica
    Composite[n_Integer] := FixedPoint[n + PrimePi@# + 1 &, n + PrimePi@n + 1]; f[1] = 1; f[n_] := If[ PrimeQ@n, Composite@ PrimePi@n, Prime[n - 1 - PrimePi@n]]; Array[f, 65] (* Robert G. Wilson v, Jun 08 2010 *)

Formula

a(1) = 1 and a(n) = if n is prime then A002808(A049084(n)) else A000040(A066246(n)) for n>1. - Reinhard Zumkeller, Dec 13 2001

Extensions

More terms from Robert G. Wilson v, Jun 08 2010

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.

A091246 Inverse function of A091242: position in A091242 if the n-th GF(2)[X] polynomial is reducible, 0 otherwise.

Original entry on oeis.org

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

Views

Author

Antti Karttunen, Jan 03 2004

Keywords

Comments

Analogous to A066246.

Crossrefs

Inverse of A091242.

Formula

a(n) = A091245(n) * A091247(n).
Showing 1-10 of 15 results. Next