Prime number generator in Scala