login
Least number coprime to n and n+1.
14

%I #25 Sep 25 2021 06:49:46

%S 3,5,5,3,7,5,3,5,7,3,5,5,3,11,7,3,5,5,3,11,5,3,5,7,3,5,5,3,7,7,3,5,5,

%T 3,11,5,3,5,7,3,5,5,3,7,7,3,5,5,3,7,5,3,5,7,3,5,5,3,7,7,3,5,5,3,7,5,3,

%U 5,11,3,5,5,3,7,7,3,5,5,3,7,5,3,5,11,3,5,5,3,7,11,3,5,5,3,7,5,3,5,7,3,5

%N Least number coprime to n and n+1.

%C A179675(n) = smallest m such that a(m) = n-th odd prime. - _Reinhard Zumkeller_, Jul 23 2010

%H Reinhard Zumkeller, <a href="/A053670/b053670.txt">Table of n, a(n) for n = 1..10000</a>

%t a[n_] := For[k = 3, True, k++, If[CoprimeQ[k, n, n+1], Return[k]]]; Table[a[n], {n, 1, 101}] (* _Jean-François Alcover_, Sep 20 2012 *)

%o (Haskell)

%o a053670 n = head [x | x <- [3, 5 ..],

%o n `gcd` x == 1, (n + 1) `gcd` x == 1]

%o -- _Reinhard Zumkeller_, Dec 28 2012

%o (PARI) a(n)=my(N=n*(n+1),k=2); while(gcd(k++,N)>1,); k \\ _Charles R Greathouse IV_, Nov 10 2015

%o (Python)

%o from math import gcd

%o def a(n):

%o k, m = 3, n*(n+1)

%o while gcd(k, m) != 1: k += 2

%o return k

%o print([a(n) for n in range(1, 102)]) # _Michael S. Branicky_, Sep 25 2021

%Y Cf. A053669-A053674.

%K nonn,nice,easy

%O 1,1

%A _Henry Bottomley_, Feb 15 2000

%E More terms from Andrew Gacek (andrew(AT)dgi.net), Feb 21 2000 and _James A. Sellers_, Feb 22 2000