Function Repository Resource:

SmoothIntegerQ

Test whether the prime factors of an integer are less than a given threshold

Contributed by: Kevin Reiss and Zachary Shelton
 ResourceFunction["SmoothIntegerQ"][n,p] returns True if there is no prime factor of n greater than p and False otherwise. ResourceFunction["SmoothIntegerQ"][p] represents an operator form of ResourceFunction["SmoothIntegerQ"] that can be applied to an integer.

Details

An integer is said to be p-smooth if its largest prime factor is less than or equal to p.
p can be any positive real; the largest prime less than or equal to p is used.
For negative integers n, n is considered p-smooth if Abs[n] is p-smooth.

Examples

Basic Examples (2)

Show that 54 is 7-smooth:

 In[1]:=
 Out[1]=

54 is not 2-smooth, since its prime factors are 2 and 3:

 In[2]:=
 Out[2]=

Scope (2)

The following is an operator which tests whether an integer is 7-smooth:

 In[3]:=
 Out[3]=
 In[4]:=
 Out[4]=

An integer is p-smooth for non-prime p if it is p-smooth for p being the greatest prime less than p:

 In[5]:=
 Out[5]=

π - smooth numbers are the same as 3-smooth numbers:

 In[6]:=
 Out[6]=

Applications (1)

Print the 7-smooth numbers less than or equal to 100:

 In[7]:=
 Out[7]=

Properties and Relations (3)

A negative integer is considered smooth if its absolute value is smooth:

 In[8]:=
 Out[8]=

Test that if n is 5-smooth, then so is -n for n up to 100:

 In[9]:=
 Out[9]=

Any input besides an integer in the first argument gives False:

 In[10]:=
 Out[10]=
 In[11]:=
 Out[11]=

Negative values for the second input always return False:

 In[12]:=
 Out[12]=
 In[13]:=
 Out[13]=

Neat Examples (2)

Calculate the number of "humble numbers" (7-smooth integers) with 1, 2, 3, 4 and 5 digits:

 In[14]:=
 Out[14]=

123200 and 123201 comprise the largest consecutive pair that are both 13-smooth:

 In[15]:=
 Out[15]=

Kevin Reiss

Version History

• 1.0.0 – 21 June 2021

Author Notes

This Function Repository submission was created live as a part of the Kevin + Zach livecoding series: Building a function the #WolframWay–YouTube.