Counting primes

Report a typo

Finish the program that counts all the prime numbers in a range of integers until nn. If n<2n<2, there will be no prime numbers.

Sample Input 1:

1

Sample Output 1:

0
Write a program in Scala 3
object PrimeCounter extends App {
var list = ???
def count(i: Int, n: Int): Unit =
if (i <= n) {
val zeroModWithPrime = list.filter(prime => i % prime == ???)
if (zeroModWithPrime.isEmpty) list = i :: list
count(i + 1, ???)
}

val n = scala.io.StdIn.readInt()
if (n < 2)
???
else {
count(2, n)
println(???)
}
}
___

Create a free account to access the full topic