Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #17 Jan 25 2017 08:39:29
%S 1,3,4,9,11,12,13,15,16,33,37,42,43,117,154,159,163,168,173,231,338,
%T 555,557,558,649,1161,1168,1209,1213,1254,1259,1263,1406,1467,1573,
%U 1578,1579,2595,2752,2805,2813,2964,2969,2997,3014,5013,5021,5022,5057,5115
%N a(1)=1, a(2)=3; 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.
%C Using the Chinese remainder theorem, it is easy to prove that the sequence is infinite.
%H Alois P. Heinz, <a href="/A172980/b172980.txt">Table of n, a(n) for n = 1..500</a>
%p a:= proc(n) option remember;
%p local ok, m, k;
%p if n<3 then 2*n-1
%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 a[1]=1; a[2]=3; a[n_] := a[n] = For[k = a[n-1]+1, True, k++, If[AllTrue[ Range[n-1], CoprimeQ[k, a[#]] == CoprimeQ[n, #]&], Return[k]]]; Table[ a[n], {n, 1, 100}] (* _Jean-François Alcover_, Jan 25 2017 *)
%Y Cf. 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