Examples
            
          
          
            
          
          
            
            
            Basic Examples (2) 
Find the closest prime to 100:
Find the closest prime to 15:
Properties and Relations (3) 
The input to ClosestPrime need not be an integer:
Symbolically specified numbers may also be used:
Negative numbers are not considered to be prime. Inputting a negative number will always return 2:
ClosestPrime is similar but not identical to NextPrime. ClosestPrime[n] returns the prime number to closest to n, considering numbers less than, equal to, or greater than n. NextPrime[n] returns the closest prime number to n, considering only numbers greater than n:
 
          
            Publisher
            Wolfram|Alpha Math Team
          
          
          
          
          Version History
  
    - 
      2.0.0
      
        
          – 23 March 2023
        
      
      
      
    
- 
      1.1.0
      
        
          – 12 May 2021
        
      
      
      
    
- 
      1.0.0
      
        
          – 10 April 2020
        
      
      
      
    
Related Resources