A020639 Lpf(n): least prime dividing n (when n > 1); a(1) = 1. Or, smallest prime factor of n, or smallest prime divisor of n.
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, 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, 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
Offset: 1
References
- D. S. Mitrinovic et al., Handbook of Number Theory, Kluwer, Section IV.1.
Links
- Daniel Forgues, Table of n, a(n) for n = 1..100000 (terms 1..10000 from T. D. Noe)
- A. E. Brouwer, Two number theoretic sums, Stichting Mathematisch Centrum. Zuivere Wiskunde, Report ZW 19/74 (1974): 3 pages. [Copy included with the permission of the author.]
- OEIS Wiki, Least prime factor of n
- David Singmaster, Letter to N. J. A. Sloane, Oct 3 1982.
- Eric Weisstein's World of Mathematics, Least Prime Factor
- Index entries for "core" sequences
Crossrefs
Programs
-
Haskell
a020639 n = spf a000040_list where spf (p:ps) | n < p^2 = n | mod n p == 0 = p | otherwise = spf ps -- Reinhard Zumkeller, Jul 13 2011
-
Maple
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
-
Mathematica
f[n_]:=FactorInteger[n][[1,1]]; Join[{1}, Array[f,120,2]] (* Robert G. Wilson v, Apr 06 2011 *) Join[{1}, Table[If[EvenQ[n], 2, FactorInteger[n][[1,1]]], {n, 2, 120}]] (* Zak Seidov, Nov 17 2013 *) Riffle[Join[{1},Table[FactorInteger[n][[1,1]],{n,3,101,2}]],2] (* Harvey P. Dale, Dec 16 2021 *)
-
PARI
A020639(n) = { vecmin(factor(n)[,1]) } \\ [Will yield an error for n = 1.] - R. J. Mathar, Mar 02 2012
-
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
-
Python
from sympy import factorint def a(n): return 1 if n == 1 else min(factorint(n)) print([a(n) for n in range(1, 98)]) # Michael S. Branicky, Dec 09 2021
-
Sage
def A020639_list(n) : return [1] + [prime_divisors(n)[0] for n in (2..n)] A020639_list(97) # Peter Luschny, Jul 16 2012
-
Sage
[trial_division(n) for n in (1..100)] # Giuseppe Coppoletta, May 25 2016
-
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
Formula
For n > 1: a(n) = A240694(n,2). - Reinhard Zumkeller, Apr 10 2014
a(n) has average order n/(2 log n) [Brouwer] - N. J. A. Sloane, Sep 03 2017
Extensions
Deleted wrong comment from M. Lagneau in 2012, following an observation by Gionata Neri. - M. F. Hasler, Aug 11 2015
Edited by M. F. Hasler, Nov 06 2017
Expanded definition to make this easier to find. - N. J. A. Sloane, Sep 21 2020
Comments