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

A246348 a(1)=1, a(p_n) = 1 + a(n), a(c_n) = 1 + a(n), where p_n = n-th prime = A000040(n), c_n = n-th composite number = A002808(n); Also binary width of terms of A135141.

Original entry on oeis.org

1, 2, 3, 2, 4, 3, 3, 4, 3, 5, 5, 4, 4, 4, 5, 4, 4, 6, 5, 6, 5, 5, 4, 5, 6, 5, 5, 7, 6, 6, 6, 7, 6, 6, 5, 6, 5, 7, 6, 6, 5, 8, 5, 7, 7, 7, 6, 8, 7, 7, 6, 7, 5, 6, 8, 7, 7, 6, 5, 9, 7, 6, 8, 8, 8, 7, 6, 9, 8, 8, 7, 7, 6, 8, 6, 7, 9, 8, 6, 8, 7, 6, 5, 10, 8, 7, 9, 9, 6, 9, 8, 7, 10
Offset: 1

Views

Author

Antti Karttunen, Aug 27 2014

Keywords

Comments

If n = 1, the result is 1, otherwise, if n is prime, compute the result for that prime's index (A000720 or A049084) and add one, and if n is composite, compute the result for that composite's index (A065855) and add one.
a(n) tells how many calls (including the toplevel call) are required to compute A135141(n) or A246377(n) with a simple (nonmemoized) recursive algorithm as employed for example by Robert G. Wilson v's Mathematica-program of Feb 16 2008 in A135141 or Antti Karttunen's Scheme-proram in A246377.

Crossrefs

Programs

Formula

a(1) = 1, and for n >= 1, if A010051(n)=1 [that is, when n is prime], a(n) = 1 + a(A000720(n)), otherwise a(n) = 1 + a(A065855(n)). [A000720(n) and A065855(n) tell the number of primes, and respectively, composites <= n].
a(n) = A246369(n) + A246370(n).
a(n) = A070939(A135141(n)) = 1 + floor(log_2(A135141(n))). [Sequence gives also the binary width of terms of A135141].
a(n) = A070939(A246377(n)). [Also for 0/1-swapped version of that sequence].

A246363 Permutation of natural numbers: a(n) = A135141(A048673(n)).

Original entry on oeis.org

1, 2, 4, 8, 3, 9, 5, 13, 10, 16, 6, 14, 7, 12, 35, 20, 17, 79, 11, 67, 71, 33, 19, 271, 39, 31, 139, 87, 15, 30, 18, 311, 47, 34, 63, 74, 23, 29, 26, 351, 21, 28, 27, 24, 303, 69, 25, 2431, 70, 223, 135, 319, 37, 1663, 65, 58, 41, 38, 32, 219, 43, 127, 367, 327, 287, 239, 55, 107, 46, 283, 22, 413, 51, 53, 147
Offset: 1

Views

Author

Antti Karttunen, Aug 26 2014

Keywords

Comments

Apart from 2, even numbers occur only in positions given by A246261 (together with some odd numbers).
Also, apart from A246263(1) = 2, the positions given by the rest of A246263: 5, 6, 7, 8, 15, 17, 18, 19, 20, 21, ... contain odd numbers only.

Crossrefs

Inverse: A246364.
Related or similar permutations: A048673, A135141, A246365, A246367.

Programs

Formula

a(n) = A135141(A048673(n)).

A246367 Permutation of natural numbers: a(n) = A005940(A135141(n)).

Original entry on oeis.org

1, 2, 4, 3, 8, 5, 6, 7, 9, 11, 16, 15, 10, 25, 21, 27, 12, 33, 14, 13, 45, 35, 18, 75, 63, 81, 49, 99, 22, 55, 32, 39, 135, 105, 125, 225, 30, 189, 243, 147, 20, 297, 50, 65, 165, 17, 42, 117, 405, 315, 375, 675, 54, 175, 567, 729, 441, 77, 24, 891, 66, 245, 195, 495, 51, 275, 28, 351, 1215, 945, 26
Offset: 1

Views

Author

Antti Karttunen, Aug 26 2014

Keywords

Crossrefs

Inverse: A246368.
Related or similar permutations: A005940, A135141, A246363, A246365.

Programs

Formula

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

A246370 a(1)=0, a(p_n) = 1 + a(n), a(c_n) = a(n), where p_n = n-th prime = A000040(n), c_n = n-th composite number = A002808(n); Also number of nonleading 0-bits in the binary representation of A135141(n).

Original entry on oeis.org

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

Views

Author

Antti Karttunen, Aug 27 2014

Keywords

Examples

			Consider n=30. It is the 19th composite number in A002808: 4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30, ...
Thus we consider next n=19, which is the 8th prime in A000040: 2, 3, 5, 7, 11, 13, 17, 19, ...
So we proceed with n=8, which is the 3rd composite number, and then with n=3, which is the 2nd prime, and then with n=2 which is the 1st prime, and we have finished.
All in all, it took us 5 steps (A246348(30) = 6 = 5+1) to reach 1, and on the journey, we encountered three primes, 19, 3 and 2, thus a(30) = 3.
		

Crossrefs

Formula

a(1) = 1, and for n >= 1, if A010051(n) = 1 [i.e. when n is prime], a(n) = 1 + a(A000720(n)), otherwise a(n) = a(A065855(n)). [A000720(n) and A065855(n) tell the number of primes, and respectively, composites <= n].
a(n) = A080791(A135141(n)). [a(n) tells also the number of nonleading zeros in binary representation of A135141(n)].
a(n) = A000120(A246377(n))-1. [Respectively, one less than the number of 1-bits in 0/1-swapped version of that sequence].
a(n) = A246348(n) - A246369(n) - 1.

A246347 Record values in A135141.

Original entry on oeis.org

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, 1179647, 1310719, 2359295, 2621439, 4718591, 5242879, 9437183, 10485759
Offset: 1

Views

Author

Antti Karttunen, Aug 27 2014 after Robert G. Wilson v's note in A135141

Keywords

Comments

In binary, the terms of the sequence seem to follow a simple pattern:
1 = a(1)
10 = a(2)
100 = a(3)
1000 = a(4)
1001 = a(5)
10001 = a(6)
10011 = a(7)
100011 = a(8)
100111 = a(9)
1000111 = a(10)
1001111 = a(11)
10001111 = a(12)
10011111 = a(13)
100011111 = a(14)
100111111 = a(15)
...
thus the sequence seems to consist of, after 1 and 2, an interleaving of sequence A153894: 4, 9, 19, 39, 79, 159, 319, ... with the sequence A052996 from its third term onward: 8, 17, 35, 71, 143, ...

Crossrefs

A246346 gives the corresponding positions in A135141.

Programs

  • Mathematica
    Union[FromDigits[#,2]&/@Flatten[Table[{PadRight[{1,0,0},n,1],PadRight[ {1,0,0,0},n,1]},{n,30}],1]] (* Harvey P. Dale, May 03 2015 *)
  • PARI
    \\ See code in A246348.
    
  • Scheme
    (define (A246347 n) (A135141 (A246346 n)))

Formula

a(n) = A135141(A246346(n)).

A246365 Permutation of natural numbers: a(n) = A135141(A005940(n)).

Original entry on oeis.org

1, 2, 4, 3, 8, 5, 7, 9, 6, 17, 19, 11, 39, 35, 25, 15, 16, 13, 23, 33, 29, 37, 75, 27, 95, 87, 61, 55, 767, 45, 83, 67, 10, 21, 47, 71, 159, 143, 139, 51, 319, 175, 639, 287, 251, 263, 247, 135, 527, 239, 199, 447, 105, 115, 991, 119, 1015, 443, 4575, 85, 583, 2175, 1343, 151, 12, 31, 63, 69, 131, 77
Offset: 1

Views

Author

Antti Karttunen, Aug 26 2014

Keywords

Comments

Even terms occur at the positions 2^n + 1 (A000051), in some order, and the odd terms everywhere else.

Crossrefs

Inverse: A246366.
Related or similar permutations: A005940, A135141, A246363, A246367.

Programs

Formula

a(n) = A135141(A005940(n)).

A246369 a(1)=0, a(p_n) = a(n), a(c_n) = 1 + a(n), where p_n = n-th prime = A000040(n), c_n = n-th composite number = A002808(n); Also one less than the binary weight of terms of A135141.

Original entry on oeis.org

0, 0, 0, 1, 0, 1, 1, 1, 2, 1, 0, 2, 1, 2, 2, 3, 1, 2, 1, 1, 3, 2, 2, 3, 3, 4, 2, 3, 1, 2, 0, 2, 4, 3, 3, 4, 2, 4, 5, 3, 1, 4, 2, 2, 3, 1, 2, 3, 5, 4, 4, 5, 3, 3, 5, 6, 4, 2, 1, 5, 2, 3, 3, 4, 2, 3, 1, 4, 6, 5, 1, 5, 3, 6, 4, 4, 6, 7, 2, 5, 3, 2, 2, 6, 3, 4, 4, 5, 3, 3, 4, 2, 5, 7, 6, 2, 3, 6, 4, 7, 4, 5, 2, 5, 7, 8, 3, 3, 1, 6, 4, 3, 2, 3, 7, 4, 5, 5, 6, 4
Offset: 1

Views

Author

Antti Karttunen, Aug 27 2014

Keywords

Comments

Consider the following algorithm:
Start:
If n is 1, we have finished,
Otherwise:
If n is a prime, replace it with its index among the primes, n <- A000720(n), and go back to the start.
Otherwise, if n is a composite, replace it with its index among the composites, n <- A065855(n), and go back to the start.
At some point, the process is guaranteed to reach the number 1 at which point we stop.
a(n) tells how many times a composite number was encountered in the process, before 1 was reached. This count includes also +1 for the cases where the initial n was composite at the beginning.

Examples

			Consider n=30. It is the 19th composite number in A002808: 4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30, ...
Thus we consider next n=19, which is the 8th prime in A000040: 2, 3, 5, 7, 11, 13, 17, 19, ...
So we proceed with n=8, which is the 3rd composite number, and then with n=3, which is the 2nd prime, and then with n=2 which is the 1st prime, and we have finished.
All in all, it took us 5 steps (A246348(30) = 6 = 5+1) to reach 1, and on the journey, we encountered two composites, 30 and 8, thus a(30) = 2.
		

Crossrefs

Formula

a(1) = 1, and for n >= 1, if A010051(n) = 1 [that is, when n is prime], a(n) = a(A000720(n)), otherwise a(n) = 1 + a(A065855(n)). [A000720(n) and A065855(n) tell the number of primes, and respectively, composites <= n].
a(n) = A000120(A135141(n)) - 1. [a(n) is also one less than the Hamming weight (number of 1-bits) of the n-th term of A135141].
a(n) = A080791(A246377(n)). [Respectively, the number of 0-bits for 0/1-swapped version of that sequence].
a(n) = A246348(n) - A246370(n) - 1.

A246346 Positions of records in A135141.

Original entry on oeis.org

1, 2, 3, 5, 8, 10, 15, 18, 25, 28, 38, 42, 55, 60, 77, 84, 105, 115, 140, 152, 183, 198, 235, 253, 298, 320, 372, 399, 462, 494, 566, 605, 692, 736, 838, 891, 1007, 1072, 1205, 1280, 1432, 1521, 1698, 1800, 2002, 2120, 2352, 2488, 2755, 2910, 3210, 3387, 3731, 3934, 4322, 4552, 4990, 5250
Offset: 1

Views

Author

Antti Karttunen, Aug 27 2014

Keywords

Comments

Bisection 2, 5, 10, 18, 28, 42, ... seems to give the positions of records in A246348 after the initial positions: 1, 2, 3, 5, 10, 18, 28, 42, ...
This easily follows from the pattern present in A246347, as from its fourth term onward, each two successive new records appear to have the same binary width.

Crossrefs

A246347 gives the corresponding values.

Programs

Formula

a(n) = A227413(A246347(n)).

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

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
Showing 1-10 of 44 results. Next