%I #14 Oct 18 2017 22:50:06
%S 1,3,4,5,6,7,8,11,13,17,18,19,20,23,26,27,28,29,30,31,32,35,36,37,39,
%T 41,43,45,46,47,48,49,50,53,54,55,56,59,61,67,68,71,72,73,77,79,80,83,
%U 85,87,88,89,90,91,92,95,97,99,100,101,102,103,107,109,111,113,114,115,116
%N a(1)=1. a(n) = smallest integer > a(n-1) that is coprime to n and is coprime to every (nonzero) exponent in the prime factorization of n.
%H Michael De Vlieger, <a href="/A138308/b138308.txt">Table of n, a(n) for n = 1..10000</a>
%e 8 has the prime-factorization of 2^3. The smallest integer > a(7)=8 that is coprime to both 8 and 3 is 11. (9 is not coprime to 3. 10 is not coprime to 8.) So a(8)=11.
%p A138308 := proc(n) option remember; local pfs,a,p,works ; if n = 1 then 1; else pfs := ifactors(n)[2] ; for a from procname(n-1)+1 do works := true ; if gcd(a,n) > 1 then works := false; else for p in pfs do if gcd(a,op(2,p)) > 1 then works := false; fi; end do ; end if; if works then return a; end if ; end do; end if; end: seq(A138308(n),n=1..120) ; # _R. J. Mathar_, Oct 24 2009
%t Fold[Append[#1, SelectFirst[Range[#1[[-1]] + 1, #1[[-1]] + 12], Function[k, AllTrue[Join[{#2}, FactorInteger[#2][[All, -1]] ], CoprimeQ[k, #] &]]]] &, {1}, Range[2, 69]] (* _Michael De Vlieger_, Oct 18 2017 *)
%Y Cf. A138309, A138310.
%K nonn
%O 1,2
%A _Leroy Quet_, Mar 13 2008
%E Extended beyond a(14) by _R. J. Mathar_, Oct 24 2009