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.

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.

This page as a plain text file.
%I A135141 #55 Jul 28 2025 09:00:33
%S A135141 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,
%T A135141 25,71,34,37,32,67,47,43,29,55,22,79,63,51,20,143,26,69,75,65,38,135,
%U A135141 95,87,59,111,30,45,159,127,103,41,24,287,70,53,139,151,131,77,36,271,191
%N 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.
%C A135141 A permutation of the positive integers, related to A078442.
%C A135141 a(p) is even when p is prime and is divisible by 2^(prime order of p).
%C A135141 From _Robert G. Wilson v_, Feb 16 2008: (Start)
%C A135141 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.
%C A135141 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)
%H A135141 Robert G. Wilson v, <a href="/A135141/b135141.txt">Table of n, a(n) for n = 1..10000</a>
%H A135141 Antti Karttunen, <a href="/A135141/a135141.pdf">Entanglement Permutations</a>, 2016-2017
%H A135141 <a href="/index/Pri#prime_indices">Index entries for sequences computed from indices in prime factorization</a>
%H A135141 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%F A135141 a(n) = 2*A135141((A049084(n))*chip + A066246(n)*(1-chip)) + 1 - chip, where chip = A010051(n). - _Reinhard Zumkeller_, Jan 29 2014
%F A135141 From _Antti Karttunen_, Dec 09 2019: (Start)
%F A135141 A007814(a(n)) = A078442(n).
%F A135141 A070939(a(n)) = A246348(n).
%F A135141 A080791(a(n)) = A246370(n).
%F A135141 A054429(a(n)) = A246377(n).
%F A135141 A245702(a(n)) = A245703(n).
%F A135141 a(A245704(n)) = A245701(n). (End)
%e A135141 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....
%t A135141 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 *)
%o A135141 (Maxima) /* Let pc = prime count (which prime it is), cc = composite count: */
%o A135141 pc[1]:0;
%o A135141 cc[1]:0;
%o A135141 pc[2]:1;
%o A135141 cc[4]:1;
%o A135141 pc[n]:=if primep(n) then 1+pc[prev_prime(n)] else 0;
%o A135141 cc[n]:=if primep(n) then 0 else if primep(n-1) then 1+cc[n-2] else 1+cc[n-1];
%o A135141 a[1]:1;
%o A135141 a[n]:=if primep(n) then 2*a[pc[n]] else 1+2*a[cc[n]];
%o A135141 (Haskell)
%o A135141 import Data.List (genericIndex)
%o A135141 a135141 n = genericIndex a135141_list (n-1)
%o A135141 a135141_list = 1 : map f [2..] where
%o A135141    f x | iprime == 0 = 2 * (a135141 $ a066246 x) + 1
%o A135141        | otherwise   = 2 * (a135141 iprime)
%o A135141        where iprime = a049084 x
%o A135141 -- _Reinhard Zumkeller_, Jan 29 2014
%o A135141 (Python)
%o A135141 from sympy import isprime, primepi
%o A135141 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
%o A135141 (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
%Y A135141 Cf. A000720, A007814, A010051, A026238, A078442.
%Y A135141 Cf. A246346, A246347 (record positions and values).
%Y A135141 Cf. A227413 (inverse).
%Y A135141 Cf. A071574, A245701, A245702, A245703, A245704, A246377, A236854, A237427 for related and similar permutations.
%K A135141 nonn,look
%O A135141 1,2
%A A135141 _Katarzyna Matylla_, Feb 13 2008