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 A373805 #38 Jul 09 2025 05:04:44 %S A373805 1,3,4,7,12,25,51,103,22,43,32,65,131,42,83,54,109,60,119,237,473,945, %T A373805 1889,90,181,100,199,108,217,435,871,1743,3487,6975,13951,27903,55807, %U A373805 162,323,645,1289,182,365,731,1463,2927,210,419,228,457,232,463,242,485,971,262,523,272,545,1091 %N A373805 If a(n-1) is not a prime, then a(n) = 2*a(n-1) + S; otherwise set S = -S and a(n) = prime(n) + S; start with a(1) = S = 1. %C A373805 The doubling and adding-or-subtracting 1 runs alternate between Riesel type (as in A374965) and Sierpinski type (as in A373801). The interest, as in both of those sequences, is whether the sequence will hit a Riesel or Sierpinski number. If that ever happens, from that point on the sequence will double and add +-1 for ever and no more primes will appear. %C A373805 After 4000 terms, the doubling run that began at a(2380) = 21168 wass still growing. %C A373805 This doubling run finally terminated at a(8475) = 21167 * 2^6095 + 1. See link in A373806 for decimal expansion. - _Michael De Vlieger_, Aug 12 2024 %H A373805 N. J. A. Sloane, <a href="/A373805/b373805.txt">Table of n, a(n) for n = 1..4000</a> %H A373805 Michael De Vlieger, <a href="/A373805/a373805.png">Log log scatterplot of log_10 a(n)</a>, n = 1..2^15. %H A373805 Michael De Vlieger, <a href="/A373805/a373805.txt">Compactified table of n, a(n) = m * 2^k + b</a>, n = 1..10^5, where k is the 2-adic valuation of a(n)-1 if a(n) is odd, or a(n) if a(n) is even, b = a(n) mod 2, and m = (a(n)-b)/2^k. %e A373805 We start with a(1) = S = 1. Since 1 is not a prime, a(2) = 2*1 + 1 = 3. %e A373805 3 is a prime, so now S = -1 and a(3) = prime(3) - 1 = 5-1 = 4. %e A373805 4 is not a prime, so a(4) = 2*4 - 1 = 7. %e A373805 And so on. %p A373805 # To get the first 100 terms: %p A373805 A:=Array(1..1200, 0); %p A373805 t:=1; %p A373805 A[1]:= t; S:=1; %p A373805 for n from 2 to 100 do %p A373805 if not isprime(t) then t:=2*t+S; else S:=-S; t:=ithprime(n)+S; fi; %p A373805 A[n]:=t; %p A373805 od: %p A373805 [seq(A[n], n=1..100)]; %t A373805 nn = 120; s = j = 1; {1}~Join~Reap[Do[If[PrimeQ[j], s = -s; k = Prime[n] + s, k = 2 j + s]; j = k; Sow[k], {n, 2, nn}] ][[-1, 1]] (* _Michael De Vlieger_, Aug 11 2024 *) %t A373805 m = 120; ToExpression /@ Import["https://oeis.org/A373805/a373805.txt", "Data"][[;; m, -1]] (* Generate up to m = 10^5 terms from compactified a-file, _Michael De Vlieger_, Aug 13 2024 *) %o A373805 (Python) %o A373805 from sympy import sieve, isprime %o A373805 from itertools import count, islice %o A373805 def A373805_gen(): # generator of terms %o A373805 an = S = 1 %o A373805 for n in count(2): %o A373805 yield an %o A373805 if not isprime(an): an = 2*an + S %o A373805 else: S *= -1; an = sieve[n] + S %o A373805 print(list(islice(A373805_gen(), 60))) # _Michael S. Branicky_, Aug 12 2024 %Y A373805 Cf. A374965, A373801, A373806, A373807. %K A373805 nonn %O A373805 1,2 %A A373805 _N. J. A. Sloane_, Aug 11 2024