A350877 The Sisyphus sequence: start the sequence S with a(1) = 1 and extend S with a(n)/2 when a(n) is even, otherwise with a(n) + the smallest prime not yet added.
1, 3, 6, 3, 8, 4, 2, 1, 8, 4, 2, 1, 12, 6, 3, 16, 8, 4, 2, 1, 18, 9, 28, 14, 7, 30, 15, 44, 22, 11, 42, 21, 58, 29, 70, 35, 78, 39, 86, 43, 96, 48, 24, 12, 6, 3, 62, 31, 92, 46, 23, 90, 45, 116, 58, 29, 102, 51, 130, 65, 148, 74, 37, 126, 63, 160, 80, 40, 20, 10, 5, 106, 53, 156, 78, 39, 146, 73, 182, 91
Offset: 1
Examples
S = 1, ... 1 is odd, we add the prime 2: S = 1, 3, ... 3 is odd, we add the next prime, 3: S = 1, 3, 6, ... 6 is even, we divide by 2: S = 1, 3, 6, 3, ... 3 is odd, we add the next prime, 5: S = 1, 3, 6, 3, 8, ... 8 is even we divide by 2 (etc.): S = 1, 3, 6, 3, 8, 4, 2, 1, ... 1 is odd, we add the next prime, 7: S = 1, 3, 6, 3, 8, 4, 2, 1, 8, ... 8 is even, we divide by 2 (etc.): S = 1, 3, 6, 3, 8, 4, 2, 1, 8, 4, 2, 1, ... 1 is odd, we add the next prime, 11: S = 1, 3, 6, 3, 8, 4, 2, 1, 8, 4, 2, 1, 12, ... 12 is even, we divide by 2 (etc.): S = 1, 3, 6, 3, 8, 4, 2, 1, 8, 4, 2, 1, 12, 6, 3, ... 3 is odd, we add the next prime, 13: S = 1, 3, 6, 3, 8, 4, 2, 1, 8, 4, 2, 1, 12, 6, 3, 16, ... 16 is even, we divide by 2 (etc.): S = 1, 3, 6, 3, 8, 4, 2, 1, 8, 4, 2, 1, 12, 6, 3, 16, 8, 4, 2, 1, ... 1 is odd, we add the next prime, 17: S = 1, 3, 6, 3, 8, 4, 2, 1, 8, 4, 2, 1, 12, 6, 3, 16, 8, 4, 2, 1, 18, ... 18 is even, we divide by 2: S = 1, 3, 6, 3, 8, 4, 2, 1, 8, 4, 2, 1, 12, 6, 3, 16, 8, 4, 2, 1, 18, 9, ... 9 is odd, we add the next prime, 19: S = 1, 3, 6, 3, 8, 4, 2, 1, 8, 4, 2, 1, 12, 6, 3, 16, 8, 4, 2, 1, 18, 9, 28, ... Etc.
Links
- Rémy Sigrist, Table of n, a(n) for n = 1..20000
- Michael De Vlieger, Scatterplot of a(n) n = 1..2^16.
- Michael De Vlieger, Annotated log-log scatterplot of a(n), n = 1..2^14, labeling the first 64 terms, highlighting records in red, 1's in blue, and primes in gold.
- Rémy Sigrist, Colored scatterplot of the first 100000 terms (red pixels correspond to terms following an odd term)
- N. J. A. Sloane, Table of n, a(n) for n = 1..100000
Crossrefs
Programs
-
Maple
# To produce M terms in b-file format: M:=100000; p:=1; L:=1; for n from 1 to M do if n=1 then lprint(n,L); else if (L mod 2) = 0 then L := L/2; else p:=nextprime(p); L:=L+p; fi; lprint(n,L); fi; od: # N. J. A. Sloane, Jan 28 2022
-
Mathematica
j = 1; q = 2; {j}~Join~Reap[Do[If[EvenQ[j], k = j/2, k = j + q; Set[q, NextPrime[q]]]; Sow[k]; j = k, {i, 79}]][[-1, -1]] (* Michael De Vlieger, Jan 22 2022 *) nxt[{sp_,n_,a_}]:=Module[{p=2,c},c=If[EvenQ[a],a/2,a+sp];{If[EvenQ[ a],sp,NextPrime[sp]],n+1,c}]; NestList[nxt,{2,1,1},80][[All,3]] (* Harvey P. Dale, Jan 23 2022 *)
-
PARI
{ print1 (v=1); forprime (p=2, 109, print1 (", "v+=p); while (v%2==0, print1 (", "v/=2))) } \\ Rémy Sigrist, Jan 23 2022
-
PARI
A350877_first(N,p=0)=vector(N,i,N=if(!p,p=1,N%2,N+p=nextprime(p+1),N/2)) \\ M. F. Hasler, Jan 23 2022
-
Python
from sympy import nextprime a, p = [1], 1 [a.append(a[-1]//2 if a[-1]%2 == 0 else a[-1]+(p:=nextprime(p))) for n in range(79)] print(a) # Michael S. Branicky, Jan 23 2022
Extensions
Added name Sisyphus sequence. - N. J. A. Sloane, Jan 23 2022
Comments