OFFSET
1,1
LINKS
K. Stern, Table of n, a(n) for n = 1..1000
MATHEMATICA
Last[t = GatherBy[Select[Range[4, 245], ! PrimeQ[#] &], OddQ]] - Take[First[t], Length[Last[t]]] (* Jayanta Basu, Aug 11 2013 *)
PROG
(MATLAB) composite function [a] = A160522(k) j = 1; n = 1; even = 4; while j < k n = n + 1; if isprime(n) == 1 else if mod(n, 2) == 0 else a(j, 1) = n - even; even = even + 2; j = j + 1; end end end
(PARI) m=70; v=vector(m); k=4; n=0; while(n<m, if(k%2>0&&!isprime(k), n++; v[n]=k-2*(n+1)); k++); v \\ Klaus Brockhaus, May 22 2009
(Python)
def A160522(n):
if n == 1: return 5
m, k = n, primepi(n) + n + (n>>1)
while m != k:
m, k = k, primepi(k) + n + (k>>1)
return m-(n+1<<1) # Chai Wah Wu, Aug 01 2024
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Kyle Stern, May 16 2009
EXTENSIONS
Extended and formula edited by Klaus Brockhaus, May 22 2009
STATUS
approved