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.
%I A374834 #36 Jul 23 2024 17:14:39 %S A374834 3,-2,-5,-16,9,24,59,-218,58,138,316,709,-4672,708,1563,3408,7364, %T A374834 15779,33601,-363046,33600,71181,150103,315315,660199,-9268542,660198, %U A374834 1378289,2870170,5963401,12365326,25593793,52887805,109127470,224867446,462788654,951362304,1953684017,-43964452250,1953684016 %N 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. %H A374834 Hans Havermann, <a href="/A374834/b374834.txt">Table of n, a(n) for n = 1..71</a> (terms 1..60 from Michael S. Branicky) %H A374834 Eric Angelini, <a href="https://cinquantesignes.blogspot.com/2024/07/do-we-yo-yo.html">Do we yo-yo?</a>, personal blog of the author, July 2024. %e A374834 As a(1) = 3 has an absolute prime value, we subtract the 3rd prime from 3 to form the next term: 3 - 5 = -2; %e A374834 as a(2) = -2 has an absolute prime value, we subtract the 2nd prime from -2 to form the next term: -2 - 3 = -5; %e A374834 as a(3) = -5 has an absolute prime value, we subtract the 5th prime from -5 to form the next term: -5 - 11 = -16; %e A374834 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. %t A374834 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 *) %o A374834 (Python) %o A374834 from itertools import islice %o A374834 from sympy import prime, composite, isprime %o A374834 def agen(): # generator of terms %o A374834 an = 3 %o A374834 while True: %o A374834 yield an %o A374834 if isprime(abs(an)): %o A374834 an = an - prime(abs(an)) %o A374834 else: %o A374834 an += composite(abs(an)-1) if abs(an) > 1 else 1 %o A374834 print(list(islice(agen(), 38))) # _Michael S. Branicky_, Jul 22 2024 %Y A374834 Cf. A000040, A018252. %K A374834 sign %O A374834 1,1 %A A374834 _Eric Angelini_ and _Hans Havermann_, Jul 21 2024