Primality Test

Report a typo

Scally started a project to test if the input natural number is a prime number. Help her finish the function using the pattern matching technique.

Sample Input 1:

1

Sample Output 1:

false
Write a program in Scala 3
def isPrime(input: Int, n: Int = 2): Boolean =
input match
case x if x < 2 => false
case x if n * n > x => ???
case x if ??? == 0 => false
case _ => isPrime(???, ???)
___

Create a free account to access the full topic