allocate mem(2^30) s = Map() seen(v) = mapisdefined(s, v) see(v) = mapput(s, v, 0) { see(1/1); for (n = 1, #a = vectorsmall(2^13), if (n==1, a[n] = 1, n%2, for (v = 1, oo, if (gcd(a[n-1]*a[n+1], v)==1 && !seen(p=a[n-1]/v) && !seen(q=v/a[n+1]), a[n] = v; see(p); see(q); break; ); ); ); print (n " " a[n]); if (n%2, m = 2*n; while (m<=#a, a[m] = a[n]; m *= 2; ); ); ); } quit