%I #5 Jul 09 2015 17:20:55
%S 1,4,6,2,10,3,14,12,15,5,22,8,26,7,9,18,34,16,38,24,27,11,46,20,30,13,
%T 21,32,58,25,62,28,36,17,40,33,74,19,42,35,82,39,86,48,50,23,94,44,56,
%U 45,54,60,106,51,65,49,63,29,118,52,122,31,57,66,55,64,134,70,72,68,142
%N a(n) is the smallest positive integer not yet in the sequence with gcd(n,a(n)) > 1 but a(n) != n; a(1) = 1 by convention.
%C This is a permutation of the positive integers with a(a(n)) = n.
%C Does every positive rational occur as a value of a(n)/n?
%H Ivan Neretin, <a href="/A159193/b159193.txt">Table of n, a(n) for n = 1..10000</a>
%t a = {1}; Do[AppendTo[a, Complement[Select[Range[Max[a] + 2 n], GCD[#, n] > 1 &], a, {n}][[1]]], {n, 2, 71}]; a (* _Ivan Neretin_, Jul 09 2015 *)
%o (PARI) va(n) = local(v); v=vector(n);v[1]=1;for(k=2,n,v[k]=na(v,k));v
%o na(v, k) = for(i=1,2*k,if(gcd(i,k)>1&&i!=k,if(!inv(v,k-1,i),return(i))))
%o inv(v, k, x) = for(i=1,k,if(v[i]==x,return(1)));return(0)
%K nonn
%O 1,2
%A _Franklin T. Adams-Watters_, Apr 05 2009
|