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 A084385 #25 Oct 01 2021 19:05:01 %S A084385 1,2,4,3,7,5,9,6,8,11,13,10,12,15,17,14,16,19,21,18,20,23,25,22,24,27, %T A084385 29,26,28,31,33,30,32,35,37,34,36,39,41,38,40,43,45,42,44,47,49,46,48, %U A084385 51,53,50,52,55,57,54,56,59,61,58,60,63,65,62,64,67,69,66,68,71,73,70 %N A084385 a(1) = 1; a(n+1) is the smallest number not occurring earlier and coprime to Sum_{j=1..n} a(j). %C A084385 Rearrangement of the positive integers. %C A084385 Any sequence defined in this manner (that is, a(1) is any positive integer and a(n+1) is the smallest integer not occurring earlier and coprime to Sum_{j=1..n} a(j)) is a rearrangement of all positive integers. This property is used by problem 4 of Chinese High School Mathematical Olympiad in 2018. - _Shu Shang_, Sep 29 2021 %H A084385 Reinhard Zumkeller, <a href="/A084385/b084385.txt">Table of n, a(n) for n = 1..10000</a> %H A084385 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a> %F A084385 For n > 6: a(n) = n-2 for n mod 4 = 0, a(n) = n-1 for n mod 4 = 1, a(n) = n+1 for n mod 4 = 2, a(n) = n+2 for n mod 4 = 3. - _Klaus Brockhaus_, Nov 30 2003 %e A084385 1+2+4 = 7, 3 is the smallest number not occurring earlier and coprime to 7, hence a(4) = 3. %o A084385 (PARI) used(k,v)=b=0; j=1; while(b<1&&j<=length(v),if(v[j]==k,b=1,j++)); b %o A084385 {print1(s=1,","); v=[s]; for(n=1,72,j=1; k=2; while(used(k,v)||gcd(k,s)>1,k++); v=concat(v,k); s=s+k; print1(k,","))} %o A084385 (PARI) {print1(1,",",2,",",4,",",3,",",7,",",5,",");for(n=7,73,m=n%4;d=(if(m==0,-2,if(m==1,-1,if(m==2,1,2)))); print1(n+d,","))} %o A084385 (Haskell) %o A084385 import Data.List (delete) %o A084385 a084385 n = a084385_list !! (n-1) %o A084385 a084385_list = 1 : f [2..] 1 where %o A084385 f xs s = g xs where %o A084385 g (y:ys) = if gcd s y == 1 then y : f (delete y xs) (s + y) else g ys %o A084385 -- _Reinhard Zumkeller_, Aug 15 2015 %Y A084385 Partial sums are in A111244. Cf. A064413. %Y A084385 Cf. A261351 (inverse). %K A084385 nonn %O A084385 1,2 %A A084385 _Amarnath Murthy_, May 29 2003 %E A084385 Edited, corrected and extended by _Klaus Brockhaus_, May 29 2003