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

A026240 a(n) = |s(n) - n|, where s = A026239.

Original entry on oeis.org

0, 2, 3, 2, 3, 3, 2, 3, 2, 1, 1, 1, 1, 3, 4, 7, 3, 11, 4, 11, 16, 19, 7, 19, 22, 27, 32, 33, 11, 37, 11, 39, 40, 45, 48, 53, 16, 59, 62, 63, 19, 65, 19, 65, 68, 81, 22, 83, 88, 89, 98, 99, 27, 103, 108, 111, 116, 121, 32, 121, 33, 129, 130, 133
Offset: 1

Views

Author

Keywords

A236854 Self-inverse permutation of natural numbers: a(1)=1, then a(p_n)=c_{a(n)}, a(c_n)=p_{a(n)}, where p_n = n-th prime, c_n = n-th composite.

Original entry on oeis.org

1, 4, 9, 2, 16, 7, 6, 23, 3, 53, 26, 17, 14, 13, 83, 5, 12, 241, 35, 101, 59, 43, 8, 41, 431, 11, 37, 1523, 75, 149, 39, 547, 277, 191, 19, 179, 27, 3001, 31, 157, 24, 12763, 22, 379, 859, 167, 114, 3943, 1787, 1153, 67, 1063, 10, 103, 27457, 127, 919, 89, 21
Offset: 1

Views

Author

Antti Karttunen, Feb 01 2014, based on Katarzyna Matylla's original but misplaced definition for A135044 from Feb 11 2008

Keywords

Comments

Shares with A026239 the property that the prime-positions 2, 3, 5, 7, ... contain only composite values and the composite-positions 4, 6, 8, 9, ..., etc. contain only prime values. However, instead of placing terms in those subsets in monotone order this sequence recursively permutes the order of both subsets with the emerging permutation itself, so this is a kind of "deep" variant of A026239. Alternatively, this can be viewed as yet another "entanglement permutation", where two pairs of complementary subsets of natural numbers are entangled with each other. In this case a complementary pair primes/composites (A000040/A002808) is entangled with a complementary pair composites/primes.
Maps A006508 to A007097 and vice versa.

Examples

			a(5)=c(a(3))=c(9)=16, because 5=prime(3), and the 9th composite number is c(9)=16.
Thus a(10)=prime(a(5))=prime(16)=53 (since 10 is the 5th composite), a(18)=prime(a(10))=prime(53)=241 (since 18 is the 10th composite), a(28)=prime(a(18))=prime(241)=1523.
A significant record value is a(198) = prime(a(152)) = prime(563167303) since 198=c(152); a(152)=prime(a(115)) since 152=c(115); a(115)=prime(a(84)); a(84)=prime(a(60)); a(60)=prime(a(42)); a(42)=prime(a(28)).
		

Crossrefs

Differs from A135044 for the first time at n=8, where A135044(8)=13, while here a(8)=23.

Programs

  • Mathematica
    terms = 150; cc = Select[Range[4, 2 terms^2(*empirical*)], CompositeQ]; compositePi[k_?CompositeQ] := FirstPosition[cc, k][[1]]; a[1] = 1; a[p_?PrimeQ] := a[p] = cc[[a[PrimePi[p]]]]; a[k_] := a[k] = Prime[a[ compositePi[k]]]; Array[a, terms] (* Jean-François Alcover, Mar 02 2016 *)
  • PARI
    A236854(n)={if(isprime(n), A002808(A236854(primepi(n))), n==1&&return(1);prime(A236854(n-primepi(n)-1)))} \\ without memoization: not much slower. - M. F. Hasler, Feb 03 2014
    
  • PARI
    a236854=vector(999);a236854[1]=1;A236854(n)={a236854[n]&&return(a236854[n]); a236854[n]=if(isprime(n), A002808(A236854(primepi(n))), prime(A236854(n-primepi(n)-1)))} \\ Version with memoization. - M. F. Hasler, Feb 03 2014
    
  • Python
    from sympy import primepi, prime, isprime
    def a002808(n):
        m, k = n, primepi(n) + 1 + n
        while m != k: m, k = k, primepi(k) + 1 + n
        return m # this function from Chai Wah Wu
    def a(n): return n if n<2 else a002808(a(primepi(n))) if isprime(n) else prime(a(n - primepi(n) - 1))
    print([a(n) for n in range(1, 101)]) # Indranil Ghosh, Jun 07 2017

Formula

a(1)=1, a(p_i) = A002808(a(i)) for primes with index i, a(c_j) = A000040(a(j)) for composites with index j (where 4 has index 1, 6 has index 2, and so on).

Extensions

Values double-checked by M. F. Hasler, Feb 03 2014

A249990 Start with the natural numbers, reverse the order in each pair, skip one pair, reverse the order in each triple, skip one triple, and so on.

Original entry on oeis.org

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

Views

Author

Alex Ratushnyak, Nov 27 2014

Keywords

Comments

A permutation of natural numbers generated by the following algorithm.
Start with the natural numbers. Reverse the order of numbers in each pair. Skip one pair. In the remainder (that is, "4, 3, 6, 5, 8, 7, 10, 9, 12, 11,...") reverse the order in each triple. Skip one triple. In the remainder (it starts with "7, 8, 5, 12, 9, 10") reverse the order in each tetrad. Skip one tetrad. And so on.

Examples

			Start with:
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, ...
After the first step:
2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, ...
After the 2nd step:
2, 1, 6, 3, 4, 7, 8, 5, 12, 9, 10, 13, 14, 11, 18, 15, 16, ...
After the 3rd step:
2, 1, 6, 3, 4, 12, 5, 8, 7, 14, 13, 10, 9, 16, 15, 18, 11, ...
		

Crossrefs

Cf. A252448 (inverse), A252458 (fixed points).

Programs

  • Haskell
    a249990 n = a249990_list !! (n-1)
    a249990_list = f 2 [1..] where
       f k xs = reverse ys ++ f (k + 1) (g zs) where
                g us = reverse vs ++ g ws where
                       (vs, ws) = splitAt k us
                (ys, zs) = splitAt k xs
    -- Reinhard Zumkeller, Dec 17 2014
  • Python
    TOP = 100
    a = list(range(TOP))
    for step in range(2,TOP):
        numBlocks = (len(a)-1) // step
        if numBlocks==0:  break
        a = a[:(1+numBlocks*step)]
        for pos in range(1,len(a),step):
            a[pos:pos+step] = a[pos+step-1:pos-1:-1]
        for i in range(1, step+1):  print(str(a[i]), end=',')
        a[1:] = a[step+1:]
    

A088609 a(1) = 1, a(n) is the smallest squarefree number not included earlier if n is not squarefree, else n is the smallest nonsquarefree number.

Original entry on oeis.org

1, 4, 8, 2, 9, 12, 16, 3, 5, 18, 20, 6, 24, 25, 27, 7, 28, 10, 32, 11, 36, 40, 44, 13, 14, 45, 15, 17, 48, 49, 50, 19, 52, 54, 56, 21, 60, 63, 64, 22, 68, 72, 75, 23, 26, 76, 80, 29, 30, 31, 81, 33, 84, 34, 88, 35, 90, 92, 96, 37, 98, 99, 38, 39, 100, 104, 108, 41, 112, 116
Offset: 1

Views

Author

Amarnath Murthy, Oct 16 2003

Keywords

Comments

From Antti Karttunen, Jun 04 2014: (Start)
This is a self-inverse permutation (involution) of natural numbers.
After 1, nonsquarefree numbers occur (in monotonic order) at the positions given by squarefree numbers, A005117, and squarefree numbers occur (in monotonic order) at the positions given by their complement, nonsquarefree numbers, A013929.
(End)

Crossrefs

Formula

From Antti Karttunen, Jun 04 2014: (Start)
a(1), and for n>1, if mu(n) = 0, a(n) = A005117(1+A057627(n)), otherwise, a(n) = A013929(A013928(n)). [Here mu is Moebius mu-function, A008683, which is zero only when n is a nonsquarefree number, one of the numbers in A013929].
For all n > 1, A008966(a(n)) = 1 - A008966(n), or equally, mu(a(n)) + 1 = mu(n) modulo 2. [A property shared with A243347].
(End)

Extensions

More terms from Ray Chandler, Oct 18 2003

A073922 a(1) = 1, a(n) = smallest composite number greater than n and not occurring earlier if n is prime, or smallest prime number greater than n and not occurring earlier if n is composite.

Original entry on oeis.org

1, 4, 6, 5, 8, 7, 9, 11, 13, 17, 12, 19, 14, 23, 29, 31, 18, 37, 20, 41, 43, 47, 24, 53, 59, 61, 67, 71, 30, 73, 32, 79, 83, 89, 97, 101, 38, 103, 107, 109, 42, 113, 44, 127, 131, 137, 48, 139, 149, 151, 157, 163, 54, 167, 173, 179, 181, 191, 60, 193, 62, 197, 199
Offset: 1

Views

Author

Amarnath Murthy, Aug 19 2002

Keywords

Crossrefs

Cf. A026239.

Programs

  • Maple
    p:= 1: c:= 1: R:= 1:
    for n from 2 to 100 do
      if isprime(n) then
        c:= max(c,n)+1;
        while isprime(c) do c:=c+1 od:
        R:= R,c
      else
        p:= nextprime(max(p,n));
        R:= R,p
      fi
    od:
    R; # Robert Israel, Apr 10 2024

Extensions

Extended by Ray Chandler, Apr 09 2014

A249991 Start with the natural numbers, reverse the order in each pair, skip one number, reverse the order in each triple, skip one number, and so on.

Original entry on oeis.org

2, 3, 5, 10, 12, 13, 21, 26, 28, 39, 41, 46, 54, 65, 67, 82, 84, 85, 109, 114, 122, 137, 139, 160, 178, 179, 181, 222, 230, 235, 269, 274, 276, 313, 331, 336, 370, 381, 383, 424, 426, 437, 471, 476, 536, 541, 549, 554, 618, 629, 647, 704, 706, 707, 761, 818
Offset: 1

Views

Author

Alex Ratushnyak, Nov 27 2014

Keywords

Comments

Start with the natural numbers. Reverse the order of numbers in each pair. Skip one number. In the remainder (that is, "1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11,...") reverse the order in each triple. Skip one number. In the remainder (it starts with "4, 1, 8, 5, 6, 9, 10, 7") reverse the order in each tetrad. Skip one number. And so on.

Crossrefs

Partial sums of A057031.

Programs

  • Python
    TOP = 100000
    a = list(range(TOP))
    for step in range(2,TOP):
      numBlocks = (len(a)-1) // step
      if numBlocks==0:  break
      a = a[:(1+numBlocks*step)]
      for pos in range(1,len(a),step):
        a[pos:pos+step] = a[pos+step-1:pos-1:-1]
      print(a[1], end=', ')
      a[1:] = a[2:]

A373290 a(1) = 1. Thereafter, for n prime a(n) is the smallest composite number not already a term which is not divisible by n, and for n composite a(n) is the smallest prime not already a term, which does not divide n.

Original entry on oeis.org

1, 9, 4, 3, 6, 5, 8, 7, 2, 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
Offset: 1

Views

Author

David James Sycamore, May 30 2024

Keywords

Comments

{a(1),a(2),...,a(9)} is a self-inverse permutation of the first 9 terms of A026239, and for n >= 10 a(n) = A026239(n). Since A026239 is a self-inverse permutation of the natural numbers, so is this sequence (but primes < 11 are not in order).

Examples

			For n = 2, (prime), a(2) = 9, the smallest composite number not divisible by 2.
For n = 6, (composite), a(6) = 5, the smallest novel prime which does not divide 6.
		

Crossrefs

Programs

  • Mathematica
    nn = 120; c[_] := False; a[1] = 1; c[1] = True; u = 2; v = 4;
    Do[If[PrimeQ[n],
      k = v; While[Or[c[k], PrimeQ[k], Divisible[k, n]], k++],
      k = u; While[Or[c[k], CompositeQ[k], Divisible[n, k]], k++]];
     Set[{a[n], c[k]}, {k, True}];
     If[k == u, While[Or[c[u], CompositeQ[u]], u++]];
     If[k == v, While[Or[c[v], PrimeQ[v]], v++]], {n, 2, nn}];
    Array[a, nn] (* Michael De Vlieger, May 31 2024 *)

Extensions

More terms from Michael De Vlieger, May 31 2024
Showing 1-7 of 7 results.