login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A347859
a(n) = n/2 if n/2 is a prime, else 3(n-1)/2 if (n-1)/2 is prime, else n.
0
0, 1, 2, 3, 2, 6, 3, 9, 8, 9, 5, 15, 12, 13, 7, 21, 16, 17, 18, 19, 20, 21, 11, 33, 24, 25, 13, 39, 28, 29, 30, 31, 32, 33, 17, 51, 36, 37, 19, 57, 40, 41, 42, 43, 44, 45, 23, 69, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 29, 87, 60, 61, 31, 93, 64, 65, 66, 67, 68, 69, 70
OFFSET
0,3
COMMENTS
Inspired by the "EKG permutation" A064413 which has a quite similar graph (a main ray with slope 1 and two secondary rays with slope 1/2 and 3/2) but probably not many other common properties.
PROG
(PARI) apply( {a(n)=if(!isprime(n\2), n, n%2, n\2*3, n\2)}, [0..88])
(Python)
from sympy import isprime
def a(n):
if n%2 == 0 and isprime(n//2): return n//2
if (n-1)%2 == 0 and isprime((n-1)//2): return 3*(n-1)//2
return n
print([a(n) for n in range(71)]) # Michael S. Branicky, Feb 21 2022
CROSSREFS
Cf. A064413 (EKG permutation), A100484 (twice the primes = even semiprimes).
Sequence in context: A329282 A197289 A161888 * A157224 A097914 A286633
KEYWORD
nonn,easy
AUTHOR
M. F. Hasler, Feb 14 2022
STATUS
approved