cp's OEIS Frontend

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.

A371282 a(1)=1; for n>1, a(n) = a(n-1) * k or a(n-1) - k to give the smallest, distinct positive integer, where each k can be used only once.

This page as a plain text file.
%I A371282 #29 Mar 19 2024 08:32:10
%S A371282 1,2,6,5,20,3,15,4,24,8,56,7,63,9,72,10,100,11,132,12,156,13,182,14,
%T A371282 210,16,288,17,323,18,360,19,399,21,462,22,506,23,552,25,625,26,676,
%U A371282 27,729,28,784,29,841,30,900,31,961,32,1024,33,1089,34,1156,35,1225
%N A371282 a(1)=1; for n>1, a(n) = a(n-1) * k or a(n-1) - k to give the smallest, distinct positive integer, where each k can be used only once.
%C A371282 The sequence is a permutation of the positive integers.
%H A371282 Michael S. Branicky, <a href="/A371282/b371282.txt">Table of n, a(n) for n = 1..10000</a>
%o A371282 (Python)
%o A371282 from itertools import islice
%o A371282 def agen(): # generator of terms
%o A371282     mina, an, aset, mink, kset = 1, 1, {1}, 1, set()
%o A371282     while True:
%o A371282         yield an
%o A371282         k1, ak1, k2 = 0, mina, mink
%o A371282         if mina < an:
%o A371282             for ak1 in range(mina, an-mink+1):
%o A371282                 if ak1 not in aset and an - ak1 not in kset:
%o A371282                     k1 = an - ak1
%o A371282                     break
%o A371282         while k2 in kset or an*k2 in aset:
%o A371282             k2 += 1
%o A371282         an, k = (an-k1, k1) if k1 > 0 else (an*k2, k2)
%o A371282         aset.add(an)
%o A371282         kset.add(k)
%o A371282         while mina in aset: mina += 1
%o A371282         while mink in kset: mink += 1
%o A371282 print(list(islice(agen(), 61))) # _Michael S. Branicky_, Mar 18 2024
%Y A371282 Cf. A371295 (k values), A081145 (add or subtract), A084337 (multiply or divide).
%K A371282 nonn
%O A371282 1,2
%A A371282 _Neal Gersh Tolunsky_, Mar 17 2024
%E A371282 a(13) and beyond from _Michael S. Branicky_, Mar 18 2024