%I #32 Mar 05 2020 16:14:45
%S 2,4,9,8,25,18,49,16,27,50,121,156,169,98,75,32,289,54,361,100,147,
%T 242,529,696,125,338,81,196,841,930,961,64,363,578,245,1332,1369,722,
%U 507,1640,1681,294,1849,484,2115,1058,2209,2544,343,250,867,676,2809,162
%N Least integer k > n such that all divisors of n are exactly the first divisors of k in increasing order.
%C Gcd(n,k) = n and lcm(n,k) = k; a(n)/n is a prime number.
%C a(n) is alternatively even and odd for n >= 2. A001248 (squares of primes) is a subsequence.
%H Michel Lagneau and Giovanni Resta, <a href="/A256017/b256017.txt">Table of n, a(n) for n = 1..10000</a> (first 600 terms from Michel Lagneau)
%F For p prime, a(p) = p^2. - _Michel Marcus_, Jun 02 2015
%e a(6)=18 because the divisors of 6 = {1,2,3,6} are the first divisors of 18 = {1,2,3,6,9,18}.
%p with(numtheory):nn:=100:
%p for n from 1 to nn do:
%p lst0:={}:x:=divisors(n):n0:=nops(x):ii:=0:
%p for k from 1 to 10^8 while (ii=0) do:
%p y:=divisors(k):n1:=nops(y):lst1:={}:
%p if n<>k and n1>=n0 then
%p for i from 1 to n0 do
%p lst0:=lst0 union {x[i]}:
%p od:
%p for j from 1 to n0 do
%p lst1:=lst1 union {y[j]}:
%p od:
%p if lst0=lst1
%p then
%p printf(`%d, `,k):ii:=1:
%p else fi:fi:
%p od:
%p od:
%t a[n_]:=If[n==1, 2, Block[{k= 2*n,f,d,m}, f = FactorInteger @n; If[1 == Length@f, f[[1,1]]^(1 + f[[1,2]]), d = Divisors@ n; m = Length@ d; While[ Take[ Divisors@ k, m] != d, k += n]; k]]]; Array[a, 1000] (* _Giovanni Resta_, Jun 01 2015 *)
%t adn[n_]:=Module[{d=Divisors[n],k=n+1,len},len=Length[d];While[Length[ Divisors[ k]]<len||Take[Divisors[k],len]!=d,k++];k]; Array[adn,60] (* _Harvey P. Dale_, Mar 05 2020 *)
%o (PARI) okd(k, d) = {my(dk = divisors(k)); (#dk >= #d) && (d == vector(#d, i, dk[i]));}
%o a(n) = {my(k = n+1); my(d = divisors(n)); while (! okd(k, d), k++); k;} \\ _Michel Marcus_, Jun 02 2015
%Y Cf. A001248.
%K nonn
%O 1,1
%A _Michel Lagneau_, Jun 01 2015