I am trying to solve the Project Euler, Problem 5. I have found many solutions on the Internet but I'm trying my own version (not so functional approach). I am stuck with an error: type mismatch found :Unit Required:Boolean.
object Euler5 {
def divby1to10(input: Int): Boolean = {
for (i <- 1 to 10) { // type mismatch found :Unit Required:Boolean
if (input % i == 0)
false
else true
}
}
def main(args: Array[String]): Unit = {
println(divby1to10(5))
}
}
If I remove the :Boolean, the code compiles but the output is (). Can someone help me to figure out what is wrong with this code and give me a solution for this?