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 A255140 #20 Sep 08 2022 08:46:11 %S A255140 1,4,2,7,13,20,10,19,29,40,4,17,31,46,23,40,5,24,4,25,5,28,14,39,13, %T A255140 40,20,49,7,38,19,52,13,48,24,61,99,138,69,23,65,108,18,63,109,156,78, %U A255140 127,177,228,114,38,19,74,37,94,47,106,53,114,19,82,41,106 %N A255140 a(1) = 1, a(n+1) = a(n)/gcd(a(n),n) if this gcd is > 1, else a(n+1) = a(n) + n + 2. %C A255140 A variant of A133058, less trivial than A255051: The sequence looks irregular up to index n = 82, where it enters a 4-periodic pattern (1, x, 2x, x), cf. formula. Sequence A255051 starts right from the beginning with the pattern (1, x, 2x, 2), whereas sequence A133058 enters such a pattern only at index n = 641. %H A255140 Harvey P. Dale, <a href="/A255140/b255140.txt">Table of n, a(n) for n = 1..1000</a> %F A255140 For k > 20, a(4k) = 8k + 2 = 2*a(4k +- 1), a(4k - 2) = 1; equivalently: %F A255140 a(n) = 2n + 2, n, 1 or n+2 when n = 4k+r > 81 with r = 0, 1, 2 or 3, respectively. %e A255140 a(2) = a(1) + 3 = 4, a(3) = a(2)/2 = 2, a(4) = a(3) + 5 = 7, a(5) = a(4) + 6 = 13, ... %t A255140 nxt[{n_,a_}]:=Module[{g=GCD[a,n]},{n+1,If[g>1,a/g,a+n+2]}]; NestList[nxt,{1,1},70][[All,2]] (* _Harvey P. Dale_, Oct 12 2019 *) %o A255140 (PARI) A255140_vec(N)=vector(N, n, if(gcd(N,n-1)>1||n==1, N/=gcd(N, n-1), N+=n+1)) \\ Original code simplified by _M. F. Hasler_, Jan 11 2020 %o A255140 (PARI) A255140(n)=if(n < 82, A255140_upto(n)[n], [2*n+2,n,1,n+2][n%4+1]) \\ _M. F. Hasler_, Jan 17 2020 %o A255140 (Magma) a:=[1]; for n in [2..65] do if Gcd(a[n-1],n-1) gt 1 then Append(~a, a[n-1] div Gcd(a[n-1],n-1)); else Append(~a, a[n-1] +n+1); end if; end for; a; // _Marius A. Burtea_, Jan 11 2020 %Y A255140 Cf. A133058, A255051. %K A255140 nonn,easy %O A255140 1,2 %A A255140 _M. F. Hasler_, Feb 15 2015 %E A255140 Edited by _M. F. Hasler_, Jan 11 2020