Coverage Summary for Class: PrimeGen (dev.suresh.service)

Class Class, % Method, % Branch, % Line, % Instruction, %
PrimeGen 0% (0/1) 0% (0/3) 0% (0/5) 0% (0/39)


 package dev.suresh.service
 
 import java.security.SecureRandom
 import kotlin.math.*
 import kotlin.random.*
 
 object PrimeGen {
 
   private val rand = SecureRandom().asKotlinRandom()
 
   fun random(upperbound: Int): List<Long> {
     val to = rand.nextInt(upperbound - 2) + 2
     val from = rand.nextInt(upperbound - 1) + 1
     return primeSeq(to.toLong(), from.toLong())
   }
 
   fun primeSeq(min: Long, max: Long) = (min..max).filter { it.isPrime }
 }
 
 val Long.isPrime
   get() = (2L..sqrt(this.toDouble()).toLong()).all { this % it != 0L }