This site is supported by donations to The OEIS Foundation.

 Annual appeal: Please make a donation to keep the OEIS running! Over 6000 articles have referenced us, often saying "we discovered this result with the help of the OEIS". Other ways to donate

 Hints (Greetings from The On-Line Encyclopedia of Integer Sequences!)
 A020639 Lpf(n): least prime dividing n (when n > 1); a(1) = 1. 634

%I

%S 1,2,3,2,5,2,7,2,3,2,11,2,13,2,3,2,17,2,19,2,3,2,23,2,5,2,3,2,29,2,31,

%T 2,3,2,5,2,37,2,3,2,41,2,43,2,3,2,47,2,7,2,3,2,53,2,5,2,3,2,59,2,61,2,

%U 3,2,5,2,67,2,3,2,71,2,73,2,3,2,7,2,79,2,3,2,83,2,5,2,3,2,89,2,7,2,3,2,5,2,97

%N Lpf(n): least prime dividing n (when n > 1); a(1) = 1.

%C Also, the largest number of distinct integers such that all their pairwise differences are coprime to n. - _Max Alekseyev_, Mar 17 2006

%C The unit 1 is not a prime number (although it has been considered so in the past). 1 is the empty product of prime numbers, thus 1 has no least prime factor. - _Daniel Forgues_, Jul 05 2011

%C a(n) = least m > 0 for which n! + m and n - m are not relatively prime. - _Clark Kimberling_, Jul 21 2012

%C For n > 1, a(n) = the smallest k > 1 that divides n. - _Antti Karttunen_, Feb 01 2014

%C For n > 1, records are at prime n's: 2, 3, 5, 7, 11, ... - _Zak Seidov_, Apr 29 2015

%C The initials "lpf" might be mistaken for "largest prime factor" (A009190), using "spf" for "smallest prime factor" would avoid this. - _M. F. Hasler_, Jul 29 2015

%C n = 89 is the first index > 1 for which a(n) differs from the smallest k > 1 such that (2^k + n - 2)/k is an integer. - _M. F. Hasler_, Aug 11 2015

%C From _Stanislav Sykora_, Jul 29 2017: (Start)

%C For n > 1, a(n) is also the smallest k, 1 < k <= n, for which the binomial(n,k) is not divisible by n.

%C Proof: (A) When k and n are relatively prime then binomial(n,k) is divisible by n because k*binomial(n,k) = n*binomial(n-1,k-1). (B) When gcd(n,k) > 1, one of its prime factors is the smallest; let us denote it p, p <= k, and consider the binomial(n,p) = (Product_{i=0..p-1}(n-i))/p!. Since p is a divisor of n, it cannot be a divisor of any of the ramaining numerator factors. It follows that, denoting as e the largest e > 0 such that p^e|n, the numerator is divisible by p^e but not by p^(e+1). Hence, the binomial is divisible by p^(e-1) but not by p^e and therefore not divisible by n. Applying (A), (B) to all considered values of k completes the proof. (End)

%C From _Bob Selcoe_, Oct 11 2017, edited by _M. F. Hasler_, Nov 06 2017: (Start)

%C a(n) = prime(j) when n == J (mod A002110(j)), n, j >= 1, where J is the set of numbers <= A002110(j) with smallest prime factor = prime(j). The number of terms in J is A005867(j-1). So:

%C a(n) = 2 when n == 0 (mod 2);

%C a(n) = 3 when n == 3 (mod 6);

%C a(n) = 5 when n == 5 or 25 (mod 30);

%C a(n) = 7 when n == 7, 49, 77, 91, 119, 133, 161 or 203 (mod 210);

%C etc. (End)

%D D. S. Mitrinovic et al., Handbook of Number Theory, Kluwer, Section IV.1.

%H T. D. Noe, <a href="/A020639/b020639.txt">Table of n, a(n) for n=1..10000</a> (extended to 100000 by Daniel Forgues)

%H A. E. Brouwer, <a href="/A046670/a046670.pdf">Two number theoretic sums</a>, Stichting Mathematisch Centrum. Zuivere Wiskunde, Report ZW 19/74 (1974): 3 pages. [Copy included with the permission of the author.]

%H OEIS Wiki, <a href="/wiki/Least_prime_factor_of_n">Least prime factor of n</a>

%H David Singmaster, <a href="/A005178/a005178.pdf">Letter to N. J. A. Sloane</a>, Oct 3 1982.

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/LeastPrimeFactor.html">Least Prime Factor</a>

%H <a href="/index/Cor#core">Index entries for "core" sequences</a>

%F A014673(n) = a(A032742(n)); A115561(n) = a(A054576(n)). - _Reinhard Zumkeller_, Mar 10 2006

%F A028233(n) = a(n)^A067029(n). - _Reinhard Zumkeller_, May 13 2006

%F a(n) = A027746(n,1) = A027748(n,1). - _Reinhard Zumkeller_, Aug 27 2011

%F For n > 1: a(n) = A240694(n,2). - _Reinhard Zumkeller_, Apr 10 2014

%F a(n) = A000040(A055396(n)) = n / A032742(n). - _Antti Karttunen_, Mar 07 2017

%F a(n) has average order n/(2 log n) [Brouwer] - _N. J. A. Sloane_, Sep 03 2017

%p A020639 := proc(n) if n = 1 then 1; else min(op(numtheory[factorset](n))) ; end if; end proc: seq(A020639(n),n=1..20) ; # _R. J. Mathar_, Oct 25 2010

%t f[n_]:=FactorInteger[n][[1,1]]; Join[{1}, Array[f,120,2]] (* _Robert G. Wilson v_, Apr 06 2011 *)

%t Join[{1}, Table[If[EvenQ[n], 2, FactorInteger[n][[1,1]]], {n, 2, 120}]] (* _Zak Seidov_, Nov 17 2013 *)

%o (PARI) A020639(n) = { vecmin(factor(n)[,1]) } \\ [Will yield an error for n = 1.] - _R. J. Mathar_, Mar 02 2012

%o (PARI) A020639(n)=if(n>1, if(n>n=factor(n,0)[1,1], n, factor(n)[1,1]), 1) \\ Avoids complete factorization if possible. Often the smallest prime factor can be found quickly even if it is larger than primelimit. If factoring takes too long for large n, use debugging level >= 3 (\g3) to display the smallest factor as soon as it is found. - _M. F. Hasler_, Jul 29 2015

%o a020639 n = spf a000040_list where

%o spf (p:ps) | n < p^2 = n

%o | mod n p == 0 = p

%o | otherwise = spf ps

%o -- _Reinhard Zumkeller_, Jul 13 2011

%o (Sage)

%o def A020639_list(n) : return [1] + [prime_divisors(n)[0] for n in (2..n)]

%o A020639_list(97) # _Peter Luschny_, Jul 16 2012

%o (Scheme) (define (A020639 n) (if (< n 2) n (let loop ((k 2)) (cond ((zero? (modulo n k)) k) (else (loop (+ 1 k))))))) ;; _Antti Karttunen_, Feb 01 2014

%o (Sage) [trial_division(n) for n in (1..100)] # _Giuseppe Coppoletta_, May 25 2016

%Y Cf. A090368 (bisection).

%Y Cf. A000040, A009190, A006530, A034684, A028233, A034699, A053585.

%Y Cf. A046669 (partial sums), A072486 (partial products).

%Y Cf. A002110, A005867.

%K nonn,easy,nice,core

%O 1,2

%A _David W. Wilson_

%E Deleted wrong comment from M. Lagneau in 2012, following an observation by _Gionata Neri_. - _M. F. Hasler_, Aug 11 2015

%E Edited by _M. F. Hasler_, Nov 06 2017

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent | More pages
The OEIS Community | Maintained by The OEIS Foundation Inc.