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 A337980 #44 Dec 22 2024 09:08:39 %S A337980 1,0,0,2,0,3,0,3,3,2,7,0,6,0,3,7,6,5,0,6,4,0,4,3,10,0,5,10,4,7,15,0,7, %T A337980 4,6,16,0,6,4,6,3,18,0,7,12,0,4,9,0,4,4,2,43,0,6,16,21,0,5,33,0,4,12, %U A337980 19,0,5,8,0,4,8,4,3,32,0,7,32,4,7,4,3,9,34,0,10,57 %N A337980 When terms first appear in the sequence they are "untouched". Start with a(1)=1. Thereafter, to find a(n), let k = a(n-1). If there is an earlier occurrence a(n-m) = k which is untouched, then a(n) = m and a(n-m) is now "touched". Otherwise, a(n) = 0. %C A337980 Similar to the Van Eck sequence A181391, except (1) A181391 starts with a 0 instead of a 1, and (2) in A181391 each nonzero term a(n) = m-1 instead of m as in the definition above. %H A337980 William Phoenix Marcum, <a href="/A337980/b337980.txt">Table of n, a(n) for n = 1..10000</a> %H A337980 William Marcum, <a href="https://www.desmos.com/calculator/gzvgcb9zgk">Desmos graph</a> %F A337980 b(n)=0 => a(n+1)=0; b(n)>0 => a(n+1)=b(n)+1; where b=A181391. - _Jan Ritsema van Eck_, Jan 09 2021 %e A337980 a(1) = 1. There is no untouched 1 before a(1), so a(2) = 0. There is no untouched 0 before a(2), so a(3) = 0. a(2) = 0, so a(4) = 2 and a(2) is marked "touched" (we can't use it again, but it is still in the sequence). No untouched 2 yet, so a(5) = 0. a(2) = 0, but it has been touched, while a(3) = 0, so a(6) = 2. %o A337980 (JavaScript) function a(n) { %o A337980 var seq = [1]; %o A337980 var accseq = []; %o A337980 for (var i = 1; i < n; i++) { %o A337980 if (accseq.indexOf(seq[seq.length-1]) == -1) { %o A337980 seq.push(0); %o A337980 } else { %o A337980 seq.push(seq.length-accseq.indexOf(seq[seq.length-1])); %o A337980 accseq[accseq.indexOf(seq[seq.length-2])] = null; %o A337980 } %o A337980 accseq.push(seq[seq.length-2]); %o A337980 } %o A337980 return seq[seq.length-1]; %o A337980 } %Y A337980 Cf. A181391. %K A337980 nonn %O A337980 1,4 %A A337980 _William Phoenix Marcum_, Oct 05 2020