Sha256: 8ed0fe5632c02af05c9fb545ff7e90839511078d203684c55a886b61c64ab8cc
Contents?: true
Size: 374 Bytes
Versions: 164
Compression:
Stored size: 374 Bytes
Contents
object NthPrime { // The stream will cache calculated primes. This is nice for performance, // but not so nice for memory utilization. private lazy val primes: Stream[BigInt] = Stream.cons(BigInt(2), primes.map(b => new BigInt(b.bigInteger.nextProbablePrime))) def prime(n: Int): Option[Int] = if (n < 1) None else Some(primes.drop(n - 1).head.toInt) }
Version data entries
164 entries across 164 versions & 1 rubygems