Jump to content

10001th prime: Difference between revisions

Line 678:
The 10001st prime is 104743.
</pre>
=={{header|Scala}}==
<syntaxhighlight lang="scala">object Prime10001 extends App {
 
val oddPrimes: LazyList[Int] = 3 #:: LazyList.from(5, 2)
.filter(p => oddPrimes.takeWhile(_ <= math.sqrt(p)).forall(p % _ > 0))
val primes = 2 #:: oddPrimes
val index = 10_001
println(s"prime($index): " + primes.drop(index - 1).take(1).head)
}</syntaxhighlight>
 
=={{header|Sidef}}==
64

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.