login
a(n) = n/2 if n/2 is a prime, else 3(n-1)/2 if (n-1)/2 is prime, else n.
0

%I #16 Feb 28 2022 10:36:10

%S 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,

%T 39,28,29,30,31,32,33,17,51,36,37,19,57,40,41,42,43,44,45,23,69,48,49,

%U 50,51,52,53,54,55,56,57,29,87,60,61,31,93,64,65,66,67,68,69,70

%N a(n) = n/2 if n/2 is a prime, else 3(n-1)/2 if (n-1)/2 is prime, else n.

%C 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.

%o (PARI) apply( {a(n)=if(!isprime(n\2), n, n%2, n\2*3, n\2)}, [0..88])

%o (Python)

%o from sympy import isprime

%o def a(n):

%o if n%2 == 0 and isprime(n//2): return n//2

%o if (n-1)%2 == 0 and isprime((n-1)//2): return 3*(n-1)//2

%o return n

%o print([a(n) for n in range(71)]) # _Michael S. Branicky_, Feb 21 2022

%Y Cf. A064413 (EKG permutation), A100484 (twice the primes = even semiprimes).

%K nonn,easy

%O 0,3

%A _M. F. Hasler_, Feb 14 2022