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.

A129145 Alternately odd prime and odd composite numbers.

This page as a plain text file.
%I A129145 #10 Aug 01 2024 14:59:46
%S A129145 3,9,5,15,7,21,11,25,13,27,17,33,19,35,23,39,29,45,31,49,37,51,41,55,
%T A129145 43,57,47,63,53,65,59,69,61,75,67,77,71,81,73,85,79,87,83,91,89,93,97,
%U A129145 95,101,99,103,105,107,111,109,115,113,117,127,119,131,121,137,123,139,125
%N A129145 Alternately odd prime and odd composite numbers.
%C A129145 For small n's a(2n) >a(2n-1) (that is for small n's, n-th odd prime less than n-th odd composite number), while for large n's a(2n) <a(2n-1) (n-th odd prime larger than n-th odd composite number), cf. A129146
%F A129145 a(2n-1)=A065091(n), a(2n) =A071904(n).
%t A129145 Module[{nn=100,pr,cm,len},pr=Prime[Range[2,nn+1]];cm=Select[Range[ 9,2nn+1,2],CompositeQ];len=Min[Length[pr],Length[cm]];Riffle[Take[ pr,len],Take[cm,len]]] (* Requires Mathematica version 10 or later *) (* _Harvey P. Dale_, May 10 2019 *)
%o A129145 (Python)
%o A129145 from sympy import prime, primepi
%o A129145 def A129145(n):
%o A129145     if n&1: return prime((n>>1)+2)
%o A129145     if n==2: return 9
%o A129145     r = n>>1
%o A129145     m, k = r, primepi(r) + r + (r>>1)
%o A129145     while m != k:
%o A129145         m, k = k, primepi(k) + r + (k>>1)
%o A129145     return m # _Chai Wah Wu_, Aug 01 2024
%Y A129145 Cf. A065091, A071904, A129131, A129146.
%K A129145 nonn
%O A129145 1,1
%A A129145 _Zak Seidov_, Apr 01 2007