%I #17 Nov 02 2012 16:12:21
%S 1,4,5,6,7,10,11,12,25,28,29,30,31,44,175,178,179,180,181,182,275,348,
%T 349,360,371,372,395,396,397,420,421,422,725,1074,1309,1310,1319,1448,
%U 2945,2954,2957,2970,2971,3016,3325,4188,4189,4190,4213,4214,4475,4526
%N a(1)=1, a(2)=4; for n>=3, a(n) is the smallest number larger than a(n-1) such that, for every k<n, a(n) is relatively prime to a(k) iff n is relatively prime to k.
%H Alois P. Heinz, <a href="/A172999/b172999.txt">Table of n, a(n) for n = 1..300</a>
%p a:= proc(n) option remember;
%p local ok, m, k;
%p if n<3 then 3*n-2
%p else for m from a(n-1)+1 do
%p ok:= true;
%p for k from 1 to n-1 do
%p if igcd(n, k)=1 xor igcd(m, a(k))=1
%p then ok:= false; break fi
%p od;
%p if ok then break fi
%p od; m
%p fi
%p end:
%p seq (a(n), n=1..50); # _Alois P. Heinz_, Nov 21 2010
%t t={1,4}; Do[nxt=t[[-1]]+1; While[CoprimeQ[n,Range[n-1]] != CoprimeQ[nxt,t], nxt++]; AppendTo[t,nxt], {n,3,50}]; t
%Y Cf. A172980, A151976, A159559, A159560, A159615, A159619, A159629, A159698, A160217.
%K nonn
%O 1,2
%A _Vladimir Shevelev_, Nov 21 2010
%E More terms from _Alois P. Heinz_, Nov 21 2010