Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,21 @@
|
|||
import scala.annotation.tailrec
|
||||
|
||||
object LoopIncrementWithinBody extends App {
|
||||
private val (limit, offset) = (42L, 1)
|
||||
|
||||
@tailrec
|
||||
private def loop(i: Long, n: Int): Unit = {
|
||||
|
||||
def isPrime(n: Long) =
|
||||
n > 1 && ((n & 1) != 0 || n == 2) && (n % 3 != 0 || n == 3) &&
|
||||
((5 to math.sqrt(n).toInt by 2).par forall (n % _ != 0))
|
||||
|
||||
if (n < limit + offset)
|
||||
if (isPrime(i)) {
|
||||
printf("n = %-2d %,19d%n".formatLocal(java.util.Locale.GERMANY, n, i))
|
||||
loop(i + i + 1, n + 1)
|
||||
} else loop(i + 1, n)
|
||||
}
|
||||
|
||||
loop(limit, offset)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue