%I #19 Mar 18 2024 09:47:04
%S 1,2,6,24,3,15,90,5,35,315,7,70,770,10,120,4,52,728,8,128,1920,12,204,
%T 3876,17,340,7140,14,308,11,253,6072,22,550,14300,13,351,9,261,8091,
%U 29,928,16,528,17952,32,1120,20,720,18,666,25308,19,779,32718,21,903,39732
%N Rearrangement of positive integers so that the successive ratios (of the larger to the smaller term) are all distinct integers. a(m)/a(m-1) = a(k)/a(k-1) iff m = k (assuming a(m) > a(m-1), otherwise the ratio a(m-1)/a(m) is to be considered). Priority is given to smallest number not included earlier rather than to the successive ratio that has not occurred earlier.
%C The sequence of successive ratios is 2/1, 6/2, 24/6, 24/3, 15/3, 90/15, 90/9, 63/9, 63/7, ... or 2, 3, 4, 8, 5, 6, 10, 7, 9, ...
%H Michael S. Branicky, <a href="/A084337/b084337.txt">Table of n, a(n) for n = 0..10000</a> (0..5000 from Ivan Neretin)
%t a = r = {1}; Do[If[(ds = Select[Divisors[a[[-1]]], ! MemberQ[a, #] && ! MemberQ[r, a[[-1]]/#] &, 1]) != {}, nxta = ds[[1]]; nxtr = a[[-1]]/nxta, k = 1; While[MemberQ[r, k] || MemberQ[a, a[[-1]]*k], k++]; nxtr = k; nxta = k*a[[-1]]]; AppendTo[a, nxta]; AppendTo[r, nxtr], {n, 57}]; a (* _Ivan Neretin_, Jul 05 2015 *)
%o (Python)
%o from sympy import divisors
%o from itertools import islice
%o def agen(): # generator of terms
%o mina, an, aset, mink, kset = 1, 1, {1}, 1, set()
%o while True:
%o yield an
%o k1, ak1, k2 = 0, mina, mink
%o if mina < an:
%o for d in divisors(an):
%o if d not in aset and an//d not in kset:
%o k1 = an//d
%o break
%o while k2 in kset or an*k2 in aset:
%o k2 += 1
%o an, k = (an//k1, k1) if k1 > 0 else (an*k2, k2)
%o aset.add(an)
%o kset.add(k)
%o while mina in aset: mina += 1
%o while mink in kset: mink += 1
%o print(list(islice(agen(), 58))) # _Michael S. Branicky_, Mar 18 2024
%K nonn
%O 0,2
%A _Amarnath Murthy_ and Meenakshi Srikanth (menakan_s(AT)yahoo.com), Jun 18 2003
%E Corrected and extended by _David Wasserman_, Dec 15 2004