Prime number sequence supporting repeated iteration
I don't like the idea of returning an inline object that inherits Sequence&lt;Long&gt; like this. Kotlin has several features to help you build stuff, including one for sequences.
Using the fantastic power of the sequence builder in Kotlin, which underneath the surface is using a suspendable function internally, we can yield numbers one by one instead of implementing an Iterator.
We can rewrite your code to use an outer object to keep the global state in, and then use a function to generate the sequence.
object Primes {
    private val knownPrimes: MutableList&lt;Long&gt; = mutableListOf(2L, 3L)
    private fun Long.isMultipleOf(n: Long) = (this % n == 0L)

    private fun Long.isPrime() = knownPrimes
            .takeWhile { it * it &lt;= this }
            .none { this.isMultipleOf(it) }

    fun sequence(): Sequence&lt;Long&gt; {
        var lastPrime: Long? = null
        return sequence {
            while (true) {
                val nextPrime = when(val actualLastPrime = lastPrime) {
                    null -&gt; 2L
                    2L -&gt; 3L
                    else -&gt; {
                        if (knownPrimes.last() &gt; actualLastPrime) {
                            knownPrimes[knownPrimes.binarySearch(actualLastPrime) + 1]
                        } else {
                            val np = generateSequence(actualLastPrime + 2) { it+2 }
                                .first { it.isPrime() }
                            knownPrimes.add(np)
                            np
                        }
                    }
                }
                lastPrime = nextPrime
                yield(nextPrime)
            }
        }
    }
}