login
A374834
Start the sequence with a(1) = 3. From now on iterate: if |a(n)| is prime, subtract from a(n) the |a(n)|-th prime of the list of primes A000040 and if |a(n)| is nonprime, add to a(n) the |a(n)|-th nonprime of the list of nonprimes A018252.
1
3, -2, -5, -16, 9, 24, 59, -218, 58, 138, 316, 709, -4672, 708, 1563, 3408, 7364, 15779, 33601, -363046, 33600, 71181, 150103, 315315, 660199, -9268542, 660198, 1378289, 2870170, 5963401, 12365326, 25593793, 52887805, 109127470, 224867446, 462788654, 951362304, 1953684017, -43964452250, 1953684016
OFFSET
1,1
LINKS
Hans Havermann, Table of n, a(n) for n = 1..71 (terms 1..60 from Michael S. Branicky)
Eric Angelini, Do we yo-yo?, personal blog of the author, July 2024.
EXAMPLE
As a(1) = 3 has an absolute prime value, we subtract the 3rd prime from 3 to form the next term: 3 - 5 = -2;
as a(2) = -2 has an absolute prime value, we subtract the 2nd prime from -2 to form the next term: -2 - 3 = -5;
as a(3) = -5 has an absolute prime value, we subtract the 5th prime from -5 to form the next term: -5 - 11 = -16;
as a(4) = -16 has an absolute nonprime value, we add the 16th nonprime to -16 to form the next term: -16 + 25 = 9; etc.
MATHEMATICA
np[n_]:=FixedPoint[n+PrimePi[#]&, n+PrimePi[n]]; (* A018252 *) seq[n_]:=If[PrimeQ[Abs[n]], n-Prime[Abs[n]], n+np[Abs[n]]]; NestList[seq, 3, 52] (* Hans Havermann, Jul 23 2024 *)
PROG
(Python)
from itertools import islice
from sympy import prime, composite, isprime
def agen(): # generator of terms
an = 3
while True:
yield an
if isprime(abs(an)):
an = an - prime(abs(an))
else:
an += composite(abs(an)-1) if abs(an) > 1 else 1
print(list(islice(agen(), 38))) # Michael S. Branicky, Jul 22 2024
CROSSREFS
Sequence in context: A301493 A214502 A077039 * A269155 A103938 A304534
KEYWORD
sign
AUTHOR
Eric Angelini and Hans Havermann, Jul 21 2024
STATUS
approved