class Prime {
    companion object {
        fun nth(x: Int): Int{
            require(x > 0)
            var count: Int = 0;
            var prime: Int = 1;
            while (count < x) {
                prime++
                if (prime.isPrime()) {
                    count++
                }
            }
            return prime
        }
    }
}

fun Int.isPrime(): Boolean{
    for (i in 2..Math.sqrt(this.toDouble()).toInt()){
        if (this.rem(i)==0) return false
    }
    return true

}