File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed 
tp2/src/main/kotlin/fmt/kotlin/fundamentals Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -4,11 +4,22 @@ fun main() {
44    println (getFirstPrimeNumbers())
55}
66
7+ private  const  val  MIN  =  0 
8+ private  const  val  MAX  =  10000 
9+ private  const  val  ERROR_MIN  =  " nbToFind must be > 0" 
10+ private  const  val  ERROR_MAX  =  " nbToFind must be < 10000" 
11+ 
712private  const  val  prefix =  " [" 
813private  const  val  separator =  " , " 
914private  const  val  suffix =  " ]" 
1015
11- fun  getFirstPrimeNumbers (nbToFind :  Int  = 10): String  {
16+ fun  getFirstPrimeNumbers (nbToFind :  Int  = 10): String  =  when  {
17+     nbToFind <=  MIN  ->  ERROR_MIN 
18+     nbToFind >  MAX  ->  ERROR_MAX 
19+     else  ->  computeFirstPrimeNumbers(nbToFind)
20+ }
21+ 
22+ private  fun  computeFirstPrimeNumbers (nbToFind :  Int  = 10): String  {
1223    var  current =  2 
1324    var  found =  " " 
1425    var  nbFound =  0 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments