A300012 A permutation of the positive integers in which adjacent terms differ by a single prime factor and a(n) has no prime factor exceeding prime(n), having the lexicographically earliest inverse.
1, 2, 6, 3, 15, 5, 10, 20, 4, 28, 14, 7, 77, 11, 22, 44, 88, 8, 24, 12, 36, 18, 9, 117, 39, 13, 26, 52, 104, 208, 16, 272, 136, 68, 34, 17, 323, 19, 57, 399, 21, 483, 69, 23, 115, 575, 25, 75, 225, 45, 135, 27, 783, 261, 87, 29, 58
Offset: 1
Keywords
Examples
From _M. F. Hasler_, Jun 13 2018: (Start) From a(1) = 1 we reach a(2) = 2 by multiplying by 2. Next we have to reach 3 as early as possible. The fastest way is to multiply by 3 (=> a(3) = 6), then divide by 2 (=> a(4) = 3). The next target to reach as early as possible is 4. But we cannot divide by a(4) by 5, nor multiply by 2 because 6 has already occurred. We must introduce an additional prime factor to multiply with. It would be possible to use 3, viz. a(4) = 3 -> 3*3 = 9 -> 9*2 = 18 -> 18*2 = 36 -> 36/3 = 12 -> 12/3 = 4 = a(9). However, choosing the larger factor 5 gives a(4) = 3 -> 3*5 = 15 -> 15/3 = 5 -> 5*2 = 10 -> 10*2 = 20 -> 20/5 = 4 = a(9). Here we visit a smaller integer (5) than using the first path, therefore this gives a lexicographically smaller inverse, and is the correct solution. Similarly, after a(118) = 50, one can reach 51 via (50, 850, 170, 85, 255, 51) or via (50, 150, 2550, 510, 102, 51). The latter comes lexicographically first, but the former fills in the smaller "hole" 85 and is the correct solution. After a(60) = 30, we can reach the next target, 31, via 30 (*31)-> 930 (/5)-> 186 (/3)-> 62 (/2)-> 31 = a(64), or via 30 (*31)-> 930 (/5)-> 186 (/2)-> 93 (/3)-> 31. The first path seems better because it visits the smaller number 62. However, using 62 here would make it impossible to reach the next target, 32, in only 6 steps (5 multiplications by 2 and one division by 31): since 31 is prime and 1 already used, we must multiply by a larger prime if 31*2 = 62 is used earlier. Therefore the "larger" path via 93 is the correct solution. A similar situation happens at n = 102 where the value of 258 must be excluded in order to reach 129 at n = 337. (End)
Links
- M. F. Hasler, Table of n, a(n) for n = 1..138
- M. F. Hasler, Table of n, a(n) for n = 1..502 (conjectural).
Programs
-
PARI
find(t,s,M=primepi(t)+1)={local(f=Vec(factor(t/s)~), best(a,b)=if(b&&cmp(Set(a),Set(b))>=0,b,a), P(i)=prod(j=1,i,f[p[j]][1]^f[p[j]][2],s),S=[],p); forstep(i=#f,1,-1, while(abs(f[i][2])>1, f=concat(f[1..i], f[i..-1]); f[i][2]-=f[i+1][2]=sign(f[i+1][2]))); while(setsearch(U,prime(M)),M++); #f>1&& for(try=0,M, p=vector(#f,i,i); for(i=1,#p-1,setsearch(U,n=P(i))||n1||(i+1<#p&&next)|| S=best(vector(#p-1,i,P(i)),S); while(n=p[i]+1;while(n<=#f&&(setsearch(Set(p[1..i-1]),n)||f[n]==f[p[i]]),n++); #f
1 && U[2]==U[1]+1,U=U[^1]));a} \\ Uses S & T to exclude, e.g., 62 until 31 is reached, cf. Example "After a(60)...". \\ M. F. Hasler, Jun 13 2018
Formula
From M. F. Hasler, Jun 13 2018: (Start)
For all n, a(n+1)/a(n) is prime or the inverse of a prime (A000040).
Comments