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 A133058 #99 Mar 18 2023 19:12:21 %S A133058 1,1,4,8,2,8,4,12,3,1,12,24,2,16,8,24,3,21,7,27,48,16,8,32,4,30,15,5, %T A133058 34,64,32,64,2,36,18,54,3,41,80,120,3,45,15,59,104,150,75,123,41,91, %U A133058 142,194,97,151,206,262,131,189,248,308,77,139,202,266,133,199,266,334,167 %N A133058 a(0) = a(1) = 1; for n > 1, a(n) = a(n-1) + n + 1 if a(n-1) and n are coprime, otherwise a(n) = a(n-1)/gcd(a(n-1),n). %C A133058 Remarkably, at n = 638 the sequence settles down and becomes quasi-periodic. - _N. J. A. Sloane_, Feb 22 2015. (Whenever I look at this sequence I am reminded of the great "Fly straight, dammit" scene in the movie "Avatar". - _N. J. A. Sloane_, Aug 06 2019) %C A133058 For every choice of initial term a(0) there exist integers r and t >= 0 such that a(2*r+4*t+0) = 1, a(2*r+4*t+1) = 2*r+4*t+3, a(2*r+4*t+2) = 2*(2*r+4*t+3), a(2*r+4*t+3) = 2. - _Ctibor O. Zizka_, Dec 26 2007 %C A133058 See also the variants A255051 (which starts immediately with the same (1, x, 2x, 2) loop that the present sequence enters at n >= 641) and A255140 (which enters a different loop at n = 82). - _M. F. Hasler_, Feb 15 2015 %C A133058 With the recurrence used here (but with different starting values), if at some point we find a(2k) = 1, then from that point on the sequence looks like (1, x, 2x, 2), (1, x+4, 2(x+4), 2), (1, x+8, 2(x+8), 2), (1, x+12, 2(x+12), 2), ... where x = 2k+3. This is just a restatement of Zizka's comment above (although I have not seen a proof that this must always happen). - _N. J. A. Sloane_, Feb 22 2015 %C A133058 It is conjectured that quasi-periodic sequences exist only for R = 0, 1, 2 or 3 in a(n) = a(n-1) + n + R and that for R >= 4 the recurrence is not quasi-periodic. For R = 0, 1, 2 all starting values give a quasi-periodic sequence. The respective loop is (1, x) for R = 0, (1, x, 2x, 2) for R = 1 (this sequence), (1, x, 2x, x) or (2x, x) for R = 2. For R = 3 only some starting values converge to a 6-loop (4x+2, 2x+1, 3x+6, x+2, 2x+9, 3x+17). - _Ctibor O. Zizka_, Oct 27 2015 %H A133058 N. J. A. Sloane, <a href="/A133058/b133058.txt">Table of n, a(n) for n = 0..10000</a>, May 26 2016 [First 1000 terms from Harvey P. Dale] %H A133058 Dana G. Korssjoen, Biyao Li, Stefan Steinerberger, Raghavendra Tripathi, and Ruimin Zhang, <a href="https://arxiv.org/abs/2012.04625">Finding structure in sequences of real numbers via graph theory: a problem list</a>, arXiv:2012.04625, Dec 08, 2020 %H A133058 N. J. A. Sloane, <a href="/A133058/a133058.png">Graph of the first 1000 terms, showing the transition from chaos to order more dramatically.</a> %H A133058 N. J. A. Sloane and Brady Haran, <a href="https://www.youtube.com/watch?v=pAMgUB51XZA">Amazing Graphs</a>, Numberphile video (2019). %H A133058 <a href="/index/Rec#order_08">Index entries for linear recurrences with constant coefficients</a>, signature (0,0,0,2,0,0,0,-1). %p A133058 A[0]:= 1: A[1]:= 1: %p A133058 for n from 2 to 1000 do %p A133058 g:= igcd(A[n-1],n); %p A133058 A[n]:= A[n-1]/g + `if`(g=1, n+1, 0); %p A133058 od: %p A133058 seq(A[i],i=0..1000); # _Robert Israel_, Nov 06 2015 %t A133058 nxt[{n_,a_}]:={n+1,If[CoprimeQ[a,n+1],a+n+2,a/GCD[a,n+1]]}; Join[{1}, Transpose[ NestList[nxt,{1,1},70]][[2]]] (* _Harvey P. Dale_, Feb 14 2015 *) %o A133058 (PARI) (A133058_upto(N)=vector(N, n, if(gcd(N,n-1)>1 || n<3, N\=gcd(N,n-1), N+=n)))(100) \\ _M. F. Hasler_, Feb 15 2015, simplified Jan 11 2020 %o A133058 (Magma) a:=[1]; for n in [2..70] do if Gcd(a[n-1],n) eq 1 then Append(~a, a[n-1] + n + 1); else Append(~a, a[n-1] div Gcd(a[n-1],n)); end if; end for; [1] cat a; // _Marius A. Burtea_, Jan 12 2020 %o A133058 (Python) %o A133058 from itertools import count, islice %o A133058 from math import gcd %o A133058 def A133058_gen(): # generator of terms %o A133058 a = 1 %o A133058 yield from (1,1) %o A133058 for n in count(2): %o A133058 yield (a:=a+n+1 if (b:=gcd(a,n)) == 1 else a//b) %o A133058 A133058_list = list(islice(A133058_gen(),30)) # _Chai Wah Wu_, Mar 18 2023 %Y A133058 Cf. A091508, A133579, A133580; A255051, A255140, A262922. %Y A133058 Quadrisections: A326991, A326992, A326993, A326994. %K A133058 nonn,look,nice,easy %O A133058 0,3 %A A133058 _Ctibor O. Zizka_, Dec 16 2007 %E A133058 More terms from _Ctibor O. Zizka_, Dec 26 2007 %E A133058 Offset and definition corrected by _N. J. A. Sloane_, Feb 13 2015