File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed 
tp2/src/main/kotlin/fmt/kotlin/fundamentals Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change 11package  fmt.kotlin.fundamentals 
22
33fun  main () {
4-     println (getFirstPrimeNumbers())
4+     println (getFirstPrimeNumbers(1 ,  2 ,  3 ))
55}
66
77private  const  val  MIN  =  0 
@@ -13,10 +13,22 @@ private const val prefix = "["
1313private  const  val  separator =  " , " 
1414private  const  val  suffix =  " ]" 
1515
16- fun  getFirstPrimeNumbers (nbToFind :  Int  = 10): String  =  when  {
17-     nbToFind <=  MIN  ->  ERROR_MIN 
18-     nbToFind >  MAX  ->  ERROR_MAX 
19-     else  ->  computeFirstPrimeNumbers(nbToFind)
16+ 
17+ fun  getFirstPrimeNumbers (vararg  nbToFindBatches :  Int ): String  {
18+     var  firstLine =  true 
19+     var  result =  " " 
20+     for  (nbToFind in  nbToFindBatches) {
21+         if  (! firstLine) {
22+             result + =  " \n " 
23+         }
24+         result + =  when  {
25+             nbToFind <=  MIN  ->  ERROR_MIN 
26+             nbToFind >  MAX  ->  ERROR_MAX 
27+             else  ->  computeFirstPrimeNumbers(nbToFind)
28+         }
29+         firstLine =  false 
30+     }
31+     return  result
2032}
2133
2234private  fun  computeFirstPrimeNumbers (nbToFind :  Int  = 10): String  {
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments