

A290151


a(n) is the smallest number larger than 1, coprime to n, and differing from n by at least 2, that has not yet appeared in the sequence.


1



5, 7, 9, 2, 11, 3, 13, 4, 17, 6, 19, 8, 23, 22, 21, 10, 25, 12, 27, 16, 15, 14, 29, 18, 31, 20, 33, 24, 37, 26, 35, 28, 39, 32, 41, 30, 43, 34, 47, 36, 53, 38, 49, 52, 51, 40, 55, 44, 57, 46, 45, 42, 59, 48, 61, 50, 63, 54, 67, 56, 65, 58, 69, 62, 71, 60, 73, 64, 79, 66, 77, 68, 81, 82, 83, 72, 85, 70, 87, 74, 75, 76, 89, 78, 91, 80, 93, 84, 97, 86, 95, 88, 99, 92, 101
(list;
graph;
refs;
listen;
history;
text;
internal format)



OFFSET

2,1


COMMENTS

It has been proved that a(n) is its own inverse, i.e., that a(a(n)) = n for all n > 1.


LINKS

Robert Israel, Table of n, a(n) for n = 2..10000
Robert Israel, Proof that a(n) is its own inverse, Mathematics Stack Exchange


EXAMPLE

a(2), must be at least 4 to differ by 2, but 4 and 2 share a factor of 2 so a(2) must be 5.
a(3), must be at least 5 but 5 is taken by a(2), so it is at least 6, but 6 shares a factor with 3 so it must be at least 7, 7 satisfies all three requirements thus a(3)=7.


MAPLE

S:= [$2..1000]:
while S <> {} do
n:= S[1];
k:= ListTools:SelectFirst(t > S[t] > n+1 and igcd(n, S[t])=1, [$2..nops(S)]);
if k = NULL then break fi;
R[n]:= S[k]; R[S[k]]:= n;
S:= subsop(1=NULL, k=NULL, S);
od:
seq(R[i], i=2..n1); # Robert Israel, Jul 25 2017


MATHEMATICA

a = {1, 5}; Do[k = 2; While[Nand[CoprimeQ[n, k], ! MemberQ[a, k], Abs[n  k] >= 2], k++]; AppendTo[a, k], {n, 3, 96}]; Rest@ a (* Michael De Vlieger, Jul 21 2017 *)


PROG

(Haskell)
f 1=[]
f nl<f$n1=l++[[ii<[2..], gcd i n<2, all(/=i)l, abs(ni)>1]!!0]
 defines a function f that when given n will generate the first n terms as a list 


CROSSREFS

Sequence in context: A104423 A011347 A296490 * A117031 A068456 A239097
Adjacent sequences: A290148 A290149 A290150 * A290152 A290153 A290154


KEYWORD

nonn


AUTHOR

Eamon Olive, Jul 21 2017


STATUS

approved



