object Sieve {
    fun primesUpTo(x: Int): List<Int>{
        val boolArray: MutableList<Boolean> = mutableListOf()
        for (i in 0..x){
            boolArray.add(true)
        }

        for (i in 2..Math.sqrt(x.toDouble()).toInt()){
            if (boolArray[i] == true){
                for (j in IntRange(i*i, x).step(i)){
                    boolArray[j] = false
                }
            }
        }

        val returnArray = mutableListOf<Int>()
        for (i in 2..boolArray.size-1){
            if (boolArray[i] == true) returnArray.add(i)
        }
        return returnArray
    }
}