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

A246368 Permutation of natural numbers: a(n) = A227413(A005941(n)).

Original entry on oeis.org

1, 2, 4, 3, 6, 7, 8, 5, 9, 13, 10, 17, 20, 19, 12, 11, 46, 23, 166, 41, 15, 29, 858, 59, 14, 71, 16, 67, 6186, 37, 58645, 31, 18, 199, 22, 83, 705348, 983, 32, 179, 10428487, 47, 184718194, 109, 21, 6659, 3840230006, 277, 27, 43, 65, 353
Offset: 1

Views

Author

Antti Karttunen, Aug 26 2014

Keywords

Crossrefs

Inverse: A246367.
Similar or related permutations: A005941, A156552, A227413, A246364, A246366.

Programs

Formula

a(n) = A227413(A005941(n)) = A227413(1+A156552(n)).
Other identities:
For all n >= 1, A010051(a(n)) = 1 - A000035(n). [This permutation maps even numbers to primes and odd numbers to nonprimes, in some order, because the permutation A227413 has the same property and A005941 preserves the parity].

A246364 Permutation of natural numbers: a(n) = A064216(A227413(n)).

Original entry on oeis.org

1, 2, 5, 3, 7, 11, 13, 4, 6, 9, 19, 14, 8, 12, 29, 10, 17, 31, 23, 16, 41, 71, 37, 44, 47, 39, 43, 42, 38, 30, 26, 59, 22, 34, 15, 85, 53, 58, 25, 130, 57, 151, 61, 311, 103, 69, 33, 365, 157, 111, 73, 226, 74, 106, 67, 370, 223, 56, 97, 341, 139, 122, 35, 133, 55, 86, 20, 145, 46, 49, 21, 659, 118, 36, 83, 419, 127, 191, 18
Offset: 1

Views

Author

Antti Karttunen, Aug 26 2014

Keywords

Comments

After a(2) = 2, the rest of the even bisection contains only terms of A246261. However, some of the terms of A246261 are also found in the odd bisection, while terms of A246263, apart from 2, all reside in the odd bisection of this sequence.

Crossrefs

Inverse: A246363.
Related or similar permutations: A064216, A227413, A246366, A246368.

Programs

Formula

a(n) = A064216(A227413(n)).

A246366 Permutation of natural numbers: a(n) = A005941(A227413(n)).

Original entry on oeis.org

1, 2, 4, 3, 6, 9, 7, 5, 8, 33, 12, 65, 18, 257, 16, 17, 10, 129, 11, 4097, 34, 2049, 19, 65537, 15, 8193, 24, 4194305, 21, 32769, 66, 1025, 20, 513, 14, 262145, 22, 16385, 13, 1099511627777, 1026, 2097153, 130, 68719476737, 30, 1048577, 35, 288230376151711745, 8194, 67108865, 40, 4398046511105, 2050, 8388609, 28
Offset: 1

Views

Author

Antti Karttunen, Aug 26 2014

Keywords

Comments

Maps even numbers to terms of A000051 (2^n + 1) in some order.

Crossrefs

Inverse: A246365.
Related or similar permutations: A005941, A156552, A227413, A246364, A246368.
Cf. A000051.

Programs

Formula

a(n) = A005941(A227413(n)) = 1 + A156552(A227413(n)).

A278526 a(n) = A046523(A227413(n)).

Original entry on oeis.org

1, 2, 4, 2, 6, 2, 4, 2, 8, 2, 12, 2, 6, 2, 16, 2, 6, 2, 6, 2, 6, 2, 6, 2, 8, 2, 24, 2, 6, 2, 6, 2, 12, 2, 12, 2, 30, 2, 4, 2, 6, 2, 6, 2, 24, 2, 6, 2, 6, 2, 24, 2, 6, 2, 36, 2, 30, 2, 6, 2, 12, 2, 6, 2, 6, 2, 32, 2, 12, 2, 12, 2, 12, 2, 12, 2, 30, 2, 6, 2, 30, 2, 16, 2, 72, 2, 12, 2, 60, 2, 12, 2, 12, 2, 4, 2, 6, 2, 48, 2, 24, 2, 6, 2, 12, 2, 6, 2, 120, 2, 12
Offset: 1

Views

Author

Antti Karttunen, Nov 30 2016

Keywords

Crossrefs

Programs

Formula

a(n) = A046523(A227413(n)).
a(n) = A278527(A054429(n)).

A007097 Primeth recurrence: a(n+1) = a(n)-th prime.

Original entry on oeis.org

1, 2, 3, 5, 11, 31, 127, 709, 5381, 52711, 648391, 9737333, 174440041, 3657500101, 88362852307, 2428095424619, 75063692618249, 2586559730396077, 98552043847093519, 4123221751654370051, 188272405179937051081, 9332039515881088707361, 499720579610303128776791, 28785866289100396890228041
Offset: 0

Views

Author

Keywords

Comments

A007097(n) = Min {k : A109301(k) = n} = the first k whose rote height is n, the level set leader or minimum inverse function corresponding to A109301. - Jon Awbrey, Jun 26 2005
Lubomir Alexandrov informs me that he studied this sequence in his 1965 notebook. - N. J. A. Sloane, May 23 2008
a(n) is the Matula-Goebel number of the rooted path tree on n+1 vertices. The Matula-Goebel number of a rooted tree can be defined in the following recursive manner: to the one-vertex tree there corresponds the number 1; to a tree T with root degree 1 there corresponds the t-th prime number, where t is the Matula-Goebel number of the tree obtained from T by deleting the edge emanating from the root; to a tree T with root degree m>=2 there corresponds the product of the Matula-Goebel numbers of the m branches of T. - Emeric Deutsch, Feb 18 2012
Conjecture: log(a(1))*log(a(2))*...*log(a(n)) ~ a(n). - Thomas Ordowski, Mar 26 2015

References

  • Lubomir Alexandrov, unpublished notes, circa 1960.
  • L. Longeri, Towards understanding nature and the aesthetics of prime numbers, https://www.longeri.org/prime/nature.html [Broken link, but leave the URL here for historical reasons]
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Row 1 of array A114537.
Left edge of tree A227413, right edge of A246378.
Cf. A078442, A109082 (left inverses).
Subsequence of A245823.

Programs

  • GAP
    P:=Filtered([1..60000],IsPrime);;
    a:=[1];; for n in [2..10] do a[n]:=P[a[n-1]]; od; a; # Muniru A Asiru, Dec 22 2018
  • Haskell
    a007097 n = a007097_list !! n
    a007097_list = iterate a000040 1  -- Reinhard Zumkeller, Jul 14 2013
    
  • Maple
    seq((ithprime@@n)(1),n=0..10); # Peter Luschny, Oct 16 2012
  • Mathematica
    NestList[Prime@# &, 1, 16] (* Robert G. Wilson v, May 30 2006 *)
  • PARI
    print1(p=1);until(,print1(","p=prime(p)))  \\ M. F. Hasler, Oct 09 2011
    

Formula

A049084(a(n+1)) = a(n). - Reinhard Zumkeller, Jul 14 2013
a(n)/a(n-1) ~ log(a(n)) ~ prime(n). - Thomas Ordowski, Mar 26 2015
a(n) = prime^{[n]}(1), with the prime function prime(k) = A000040(k), with a(0) = 1. See the name and the programs. - Wolfdieter Lang, Apr 03 2018
Sum_{n>=1} 1/a(n) = A292667. - Amiram Eldar, Oct 15 2020

Extensions

a(15) corrected and a(16)-a(17) added by Paul Zimmermann
a(18)-a(19) found by David Baugh using a program by Xavier Gourdon and Andrey V. Kulsha, Oct 25 2007
a(20)-a(21) found by Andrey V. Kulsha using a program by Xavier Gourdon, Oct 02 2011
a(22) from Henri Lifchitz, Oct 14 2014
a(23) from David Baugh using Kim Walisch's primecount, May 16 2016

A048673 Permutation of natural numbers: a(n) = (A003961(n)+1) / 2 [where A003961(n) shifts the prime factorization of n one step towards larger primes].

Original entry on oeis.org

1, 2, 3, 5, 4, 8, 6, 14, 13, 11, 7, 23, 9, 17, 18, 41, 10, 38, 12, 32, 28, 20, 15, 68, 25, 26, 63, 50, 16, 53, 19, 122, 33, 29, 39, 113, 21, 35, 43, 95, 22, 83, 24, 59, 88, 44, 27, 203, 61, 74, 48, 77, 30, 188, 46, 149, 58, 47, 31, 158, 34, 56, 138, 365, 60, 98, 36, 86, 73
Offset: 1

Views

Author

Antti Karttunen, Jul 14 1999

Keywords

Comments

Inverse of sequence A064216 considered as a permutation of the positive integers. - Howard A. Landman, Sep 25 2001
From Antti Karttunen, Dec 20 2014: (Start)
Permutation of natural numbers obtained by replacing each prime divisor of n with the next prime and mapping the generated odd numbers back to all natural numbers by adding one and then halving.
Note: there is a 7-cycle almost right in the beginning: (6 8 14 17 10 11 7). (See also comments at A249821. This 7-cycle is endlessly copied in permutations like A250249/A250250.)
The only 3-cycle in range 1 .. 402653184 is (2821 3460 5639).
For 1- and 2-cycles, see A245449.
(End)
The first 5-cycle is (1410, 2783, 2451, 2703, 2803). - Robert Israel, Jan 15 2015
From Michel Marcus, Aug 09 2020: (Start)
(5194, 5356, 6149, 8186, 10709), (46048, 51339, 87915, 102673, 137205) and (175811, 200924, 226175, 246397, 267838) are other 5-cycles.
(10242, 20479, 21413, 29245, 30275, 40354, 48241) is another 7-cycle. (End)
From Antti Karttunen, Feb 10 2021: (Start)
Somewhat artificially, also this permutation can be represented as a binary tree. Each child to the left is obtained by multiplying the parent by 3 and subtracting one, while each child to the right is obtained by applying A253888 to the parent:
1
|
................../ \..................
2 3
5......../ \........4 8......../ \........6
/ \ / \ / \ / \
/ \ / \ / \ / \
/ \ / \ / \ / \
14 13 11 7 23 9 17 18
41 10 38 12 32 28 20 15 68 25 26 63 50 16 53 19
etc.
Each node's (> 1) parent can be obtained with A253889. Sequences A292243, A292244, A292245 and A292246 are constructed from the residues (mod 3) of the vertices encountered on the path from n to the root (1).
(End)

Examples

			For n = 6, as 6 = 2 * 3 = prime(1) * prime(2), we have a(6) = ((prime(1+1) * prime(2+1))+1) / 2 = ((3 * 5)+1)/2 = 8.
For n = 12, as 12 = 2^2 * 3, we have a(12) = ((3^2 * 5) + 1)/2 = 23.
		

Crossrefs

Inverse: A064216.
Row 1 of A251722, Row 2 of A249822.
One more than A108228, half the terms of A243501.
Fixed points: A048674.
Positions of records: A029744, their values: A246360 (= A007051 interleaved with A057198).
Positions of subrecords: A247283, their values: A247284.
Cf. A246351 (Numbers n such that a(n) < n.)
Cf. A246352 (Numbers n such that a(n) >= n.)
Cf. A246281 (Numbers n such that a(n) <= n.)
Cf. A246282 (Numbers n such that a(n) > n.), A252742 (their char. function)
Cf. A246261 (Numbers n for which a(n) is odd.)
Cf. A246263 (Numbers n for which a(n) is even.)
Cf. A246260 (a(n) reduced modulo 2), A341345 (modulo 3), A341346, A292251 (3-adic valuation), A292252.
Cf. A246342 (Iterates starting from n=12.)
Cf. A246344 (Iterates starting from n=16.)
Cf. A245447 (This permutation "squared", a(a(n)).)
Other permutations whose formulas refer to this sequence: A122111, A243062, A243066, A243500, A243506, A244154, A244319, A245605, A245608, A245610, A245612, A245708, A246265, A246267, A246268, A246363, A249745, A249824, A249826, and also A183209, A254103 that are somewhat similar.
Cf. also prime-shift based binary trees A005940, A163511, A245612 and A244154.
Cf. A253888, A253889, A292243, A292244, A292245 and A292246 for other derived sequences.
Cf. A323893 (Dirichlet inverse), A323894 (sum with it), A336840 (inverse Möbius transform).

Programs

  • Haskell
    a048673 = (`div` 2) . (+ 1) . a045965
    -- Reinhard Zumkeller, Jul 12 2012
    
  • Maple
    f:= proc(n)
    local F,q,t;
      F:= ifactors(n)[2];
      (1 + mul(nextprime(t[1])^t[2], t = F))/2
    end proc:
    seq(f(n),n=1..1000); # Robert Israel, Jan 15 2015
  • Mathematica
    Table[(Times @@ Power[If[# == 1, 1, NextPrime@ #] & /@ First@ #, Last@ #] + 1)/2 &@ Transpose@ FactorInteger@ n, {n, 69}] (* Michael De Vlieger, Dec 18 2014, revised Mar 17 2016 *)
  • PARI
    A003961(n) = my(f = factor(n)); for (i=1, #f~, f[i, 1] = nextprime(f[i, 1]+1)); factorback(f); \\ From A003961
    A048673(n) = (A003961(n)+1)/2; \\ Antti Karttunen, Dec 20 2014
    
  • PARI
    A048673(n) = if(1==n,n,if(n%2,A253888(A048673((n-1)/2)),(3*A048673(n/2))-1)); \\ (Not practical, but demonstrates the construction as a binary tree). - Antti Karttunen, Feb 10 2021
    
  • Python
    from sympy import factorint, nextprime, prod
    def a(n):
        f = factorint(n)
        return 1 if n==1 else (1 + prod(nextprime(i)**f[i] for i in f))//2 # Indranil Ghosh, May 09 2017
  • Scheme
    (define (A048673 n) (/ (+ 1 (A003961 n)) 2)) ;; Antti Karttunen, Dec 20 2014
    

Formula

From Antti Karttunen, Dec 20 2014: (Start)
a(1) = 1; for n>1: If n = product_{k>=1} (p_k)^(c_k), then a(n) = (1/2) * (1 + product_{k>=1} (p_{k+1})^(c_k)).
a(n) = (A003961(n)+1) / 2.
a(n) = floor((A045965(n)+1)/2).
Other identities. For all n >= 1:
a(n) = A108228(n)+1.
a(n) = A243501(n)/2.
A108951(n) = A181812(a(n)).
a(A246263(A246268(n))) = 2*n.
As a composition of other permutations involving prime-shift operations:
a(n) = A243506(A122111(n)).
a(n) = A243066(A241909(n)).
a(n) = A241909(A243062(n)).
a(n) = A244154(A156552(n)).
a(n) = A245610(A244319(n)).
a(n) = A227413(A246363(n)).
a(n) = A245612(A243071(n)).
a(n) = A245608(A245605(n)).
a(n) = A245610(A244319(n)).
a(n) = A249745(A249824(n)).
For n >= 2, a(n) = A245708(1+A245605(n-1)).
(End)
From Antti Karttunen, Jan 17 2015: (Start)
We also have the following identities:
a(2n) = 3*a(n) - 1. [Thus a(2n+1) = 0 or 1 when reduced modulo 3. See A341346]
a(3n) = 5*a(n) - 2.
a(4n) = 9*a(n) - 4.
a(5n) = 7*a(n) - 3.
a(6n) = 15*a(n) - 7.
a(7n) = 11*a(n) - 5.
a(8n) = 27*a(n) - 13.
a(9n) = 25*a(n) - 12.
and in general:
a(x*y) = (A003961(x) * a(y)) - a(x) + 1, for all x, y >= 1.
(End)
From Antti Karttunen, Feb 10 2021: (Start)
For n > 1, a(2n) = A016789(a(n)-1), a(2n+1) = A253888(a(n)).
a(2^n) = A007051(n) for all n >= 0. [A property shared with A183209 and A254103].
(End)
a(n) = A003602(A003961(n)). - Antti Karttunen, Apr 20 2022
Sum_{k=1..n} a(k) ~ c * n^2, where c = (1/4) * Product_{p prime} ((p^2-p)/(p^2-nextprime(p))) = 1.0319981... , where nextprime is A151800. - Amiram Eldar, Jan 18 2023

Extensions

New name and crossrefs to derived sequences added by Antti Karttunen, Dec 20 2014

A193231 Blue code for n: in binary coding of a polynomial over GF(2), substitute x+1 for x (see Comments for precise definition).

Original entry on oeis.org

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

Views

Author

Keywords

Comments

This is a self-inverse permutation of the nonnegative integers.
The function "substitute x+1 for x" on polynomials over GF(2) is completely multiplicative.
What is the density of fixed points in this sequence? Do we get a different answer if we look only at irreducible polynomials?
From Antti Karttunen, Dec 27 2013: (Start)
As what comes to the above question, the number of fixed points in range [2^(n-1),(2^n)-1] of the sequence is given by A131575(n). In range [0,0] there is one fixed point: 0, in range [1,1] there is also one: 1, in range [2,3] there are no fixed points, in range [4,7] there are two fixed points: 6 and 7, and so on. (Cf. also the C-code given in A118666.)
Similarly, the number of cycles in such ranges begins as 1, 1, 1, 3, 4, 10, 16, 36, 64, 136, ... which is A051437 shifted two steps right (prepended with 1's): Because the sequence is a self-inverse permutation, the number of its cycles in range [2^(n-1),(2^n)-1] is computed as: cycles(n) = (A011782(n)-number_of_fixedpoints(n))/2 + number_of_fixedpoints(n), which matches with the identity: A051437(n-2) = (A011782(n)-A131575(n))/2 + A131575(n), for n>=2.
In OEIS terms, the above comment about multiplicativeness can be rephrased as: a(A048720(x,y)) = A048720(a(x),a(y)) for all integers x, y >= 0. Here A048720(x,y) gives the product of carryless binary multiplication of x and y.
The permutation conjugates between Gray code and its inverse: A003188(n) = a(A006068(a(n))) and A006068(n) = a(A003188(a(n))) [cf. the identity 1.19-9d: gB = Bg^{-1} given on page 53 of fxtbook].
Because of the multiplicativity, the subset of irreducible (and respectively: composite) polynomials over GF(2) is closed under this permutation. Cf. the following mappings: a(A014580(n)) = A234750(n) and a(A091242(n)) = A234745(n).
(End)

Examples

			11, binary 1011, corresponds to polynomial x^3+x+1, substituting: (x+1)^3+(x+1)+1 = x^3+x^2+x+1 + x+1 + 1 = x^3+x^2+1, binary 1101 = decimal 13, so a(11) = 13.
From _Tilman Piesk_, Jun 26 2025: (Start)
The binary exponents of 11 are {0, 1, 3}, because 11 = 2^0 + 2^1 + 2^3.
a(11) = A001317(0) XOR A001317(1) XOR A001317(3) = 1 XOR 3 XOR 15 = 13. (End)
		

Crossrefs

Cf. A000069, A001969, A001317, A003987, A048720, A048724, A065621, A051437, A118666 (fixed points), A131575, A234022 (the number of 1-bits), A234023, A010060, A234745, A234750.
Similarly constructed permutation pairs: A003188/A006068, A135141/A227413, A232751/A232752, A233275/A233276, A233277/A233278, A233279/A233280.
Other permutations based on this (by conjugating, composing, etc): A234024, A234025/A234026, A234027, A234612, A234613, A234747, A234748, A244987, A245812, A245454.

Programs

  • Mathematica
    f[n_] := Which[0 <= # <= 1, #, EvenQ@ #, BitXor[2 #, #] &[f[#/2]], True, BitXor[#, 2 # + 1] &[f[(# - 1)/2]]] &@ Abs@ n; Table[f@ n, {n, 0, 66}] (* Michael De Vlieger, Feb 12 2016, after Robert G. Wilson v at A048724 and A065621 *)
  • PARI
    tox(n) = local(x=Mod(1,2)*X, xp=1, r); while(n>0,if(n%2,r+=xp);xp*=x;n\=2);r
    a(n)=subst(lift(subst(tox(n),X,X+1)),X,2)
    
  • PARI
    a(n)={local(x='x);subst(lift(Mod(1,2)*subst(Pol(binary(n),x),x,1+x)),x,2)};
    
  • Python
    def a065621(n): return n^(2*(n - (n&-n)))
    def a048724(n): return n^(2*n)
    l=[0, 1]
    for n in range(2, 101):
        if n%2==0: l.append(a048724(l[n//2]))
        else: l.append(a065621(1 + l[(n - 1)//2]))
    print(l) # Indranil Ghosh, Jun 04 2017
  • Scheme
    ;; with memoizing macro definec available in Antti Karttunen's IntSeq-library:
    (define (A193231 n) (let loop ((n n) (i 0) (s 0)) (cond ((zero? n) s) ((even? n) (loop (/ n 2) (+ 1 i) s)) (else (loop (/ (- n 1) 2) (+ 1 i) (A003987bi s (A001317 i))))))) ;; A003987bi implements binary XOR, A003987.
    ;; Antti Karttunen, Dec 27 2013
    
  • Scheme
    ;; With memoizing macro definec available in Antti Karttunen's IntSeq-library.
    ;; Alternative implementation, a recurrence based on entangling even & odd numbers with complementary pair A048724 and A065621:
    (definec (A193231 n) (cond ((< n 2) n) ((even? n) (A048724 (A193231 (/ n 2)))) (else (A065621 (+ (A193231 (/ (- n 1) 2)) 1)))))
    ;; Antti Karttunen, Dec 27 2013
    

Formula

From Antti Karttunen, Dec 27 2013: (Start)
a(0) = 0, and for any n = 2^a + 2^b + ... + 2^c, a(n) = A001317(a) XOR A001317(b) XOR ... XOR A001317(c), where XOR is bitwise XOR (A003987) and all the exponents a, b, ..., c are distinct, that is, they are the indices of 1-bits in the binary representation of n.
From above it follows, because all terms of A001317 are odd, that A000035(a(n)) = A010060(n) = A000035(a(2n)). Conversely, we also have A010060(a(n)) = A000035(n). Thus the permutation maps any even number to some evil number, A001969 (and vice versa), like it maps any odd number to some odious number, A000069 (and vice versa).
a(0)=0, a(1)=1, and for n>1, a(2n) = A048724(a(n)), a(2n+1) = A065621(1+a(n)). [A recurrence based on entangling even & odd numbers with the complementary pair A048724/A065621]
For all n, abs(a(2n)-a(2n+1)) = 1.
a(A000079(n)) = A001317(n).
(End)
It follows from the first paragraph above that a(A003987(n,k)) = A003987(a(n), a(k)), that is a(n XOR k) = a(n) XOR a(k). - Peter Munn, Nov 27 2019

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)

A078442 a(p) = a(n) + 1 if p is the n-th prime, prime(n); a(n)=0 if n is not prime.

Original entry on oeis.org

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

Views

Author

Henry Bottomley, Dec 31 2002

Keywords

Comments

Fernandez calls this the order of primeness of n.
a(A007097(n))=n, for any n >= 0. - Paul Tek, Nov 12 2013
When a nonoriented rooted tree is encoded as a Matula-Goebel number n, a(n) tells how many edges needs to be climbed up from the root of the tree until the first branching vertex (or the top of the tree, if n is one of the terms of A007097) is encountered. Please see illustrations at A061773. - Antti Karttunen, Jan 27 2014
Zero-based column index of n in the Kimberling-style dispersion table of the primes (see A114537). - Allan C. Wechsler, Jan 09 2024

Examples

			a(1) = 0 since 1 is not prime;
a(2) = a(prime(1)) = a(1) + 1 = 1 + 0 = 1;
a(3) = a(prime(2)) = a(2) + 1 = 1 + 1 = 2;
a(4) = 0 since 4 is not prime;
a(5) = a(prime(3)) = a(3) + 1 = 2 + 1 = 3;
a(6) = 0 since 6 is not prime;
a(7) = a(prime(4)) = a(4) + 1 = 0 + 1 = 1.
		

Crossrefs

A left inverse of A007097.
One less than A049076.
a(A000040(n)) = A049076(n).
Cf. A373338 (mod 2), A018252 (positions of zeros).
Cf. permutations A235489, A250247/A250248, A250249/A250250, A245821/A245822 that all preserve a(n).
Cf. also array A114537 (A138947) and permutations A135141/A227413, A246681.

Programs

  • Haskell
    a078442 n = fst $ until ((== 0) . snd)
                            (\(i, p) -> (i + 1, a049084 p)) (-2, a000040 n)
    -- Reinhard Zumkeller, Jul 14 2013
  • Maple
    A078442 := proc(n)
        if not isprime(n) then
            0 ;
        else
            1+procname(numtheory[pi](n)) ;
        end if;
    end proc: # R. J. Mathar, Jul 07 2012
  • Mathematica
    a[n_] := a[n] = If[!PrimeQ[n], 0, 1+a[PrimePi[n]]]; Array[a, 105] (* Jean-François Alcover, Jan 26 2018 *)
  • PARI
    A078442(n)=for(i=0,n, isprime(n) || return(i); n=primepi(n)) \\ M. F. Hasler, Mar 09 2010
    

Formula

a(n) = A049076(n)-1.
a(n) = if A049084(n) = 0 then 0 else a(A049084(n)) + 1. - Reinhard Zumkeller, Jul 14 2013
For all n, a(n) = A007814(A135141(n)) and a(A227413(n)) = A007814(n). Also a(A235489(n)) = a(n). - Antti Karttunen, Jan 27 2014

A237427 a(0)=0, a(1)=1; thereafter, if n is k-th ludic number [i.e., n = A003309(k)], a(n) = 1 + (2*a(k-1)); otherwise, when n is k-th nonludic number [i.e., n = A192607(k)], a(n) = 2*a(k).

Original entry on oeis.org

0, 1, 3, 7, 2, 15, 6, 5, 14, 4, 30, 31, 12, 13, 10, 28, 8, 11, 60, 62, 24, 26, 20, 29, 56, 9, 16, 22, 120, 61, 124, 48, 52, 40, 58, 112, 18, 63, 32, 44, 240, 25, 122, 27, 248, 96, 104, 21, 80, 116, 224, 36, 126, 57, 64, 88, 480, 50, 244, 54, 496, 17, 192, 208, 42
Offset: 0

Views

Author

Keywords

Comments

Shares with permutation A237058 the property that all odd numbers occur in positions given by ludic numbers (A003309: 1, 2, 3, 5, 7, 11, 13, 17, ...), while the even numbers > 0 occur in positions given by nonludic numbers (A192607: 4, 6, 8, 9, 10, 12, 14, 15, 16, ...). However, instead of placing terms into those positions 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 A237058.
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 ludic/nonludic numbers (A003309/A192607) is entangled with a complementary pair odd/even numbers (A005408/A005843).
Because 2 is the only even ludic number, it implies that, apart from a(2)=3, odd numbers occur in odd positions only (along with many even numbers that also occur in odd positions).

Examples

			For n=2, with 2 being the second ludic number (= A003309(2)), the value is computed as 1+(2*a(2-1)) = 1+2*a(1) = 1+2 = 3, thus a(2)=3.
For n=3, with 3 being the third ludic number (= A003309(3)), the value is computed as 1+(2*a(3-1)) = 1+2*a(2) = 1+2*3 = 7, thus a(3)=7.
For n=4, with 4 being the first nonludic number (= A192607(1)), the value is computed as 2*a(1) = 2 = a(4).
For n=5, with 5 being the fourth ludic number (= A003309(4)), the value is computed as 1+(2*a(4-1)) = 1+2*a(3) = 1+2*7 = 15 = a(5).
For n=9, with 9 being the fourth nonludic number (= A192607(4)), the value is computed as 2*a(4) = 2*2 = 4 = a(9).
		

Crossrefs

Inverse permutation of A237126.
Similar permutations: A135141/A227413, A243287/A243288, A243343-A243346.

Programs

  • Haskell
    import Data.List (elemIndex); import Data.Maybe (fromJust)
    a237427 = (+ 1) . fromJust . (`elemIndex` a237126_list)
    
  • Mathematica
    nmax = 100;
    T = Range[2, nmax+7];
    L = {1};
    While[Length[T] > 0, With[{k = First[T]},
         AppendTo[L, k]; T = Drop[T, {1, -1, k}]]];
    nonL = Complement[Range[Last[L]], L];
    a[n_] := a[n] = Module[{k}, Which[
         n < 2, n,
         IntegerQ[k = FirstPosition[L, n][[1]]], 1 + 2 a[k-1],
         IntegerQ[k = FirstPosition[nonL, n][[1]]], 2 a[k],
         True , Print[" error: n = ", n]]];
    Table[a[n], {n, 0, nmax}] (* Jean-François Alcover, Oct 10 2021, after Ray Chandler in A003309 *)
  • Scheme
    ;; With Antti Karttunen's IntSeq-library for memoizing definec-macro.
    (definec (A237427 n) (cond ((< n 2) n) ((= 1 (A192490 n)) (+ 1 (* 2 (A237427 (- (A192512 n) 1))))) (else (* 2 (A237427 (A236863 n))))))
    ;; Antti Karttunen, Feb 07 2014

Formula

a(0)=0, a(1)=1; thereafter, if A192490(n) = 1 [i.e., n is ludic], a(n) = 1+(2*a(A192512(n)-1)); otherwise a(n) = 2*a(A236863(n)) [where A192512 and A236863 give the number of ludic and nonludic numbers <= n, respectively].
Showing 1-10 of 33 results. Next