Prime number generator in scala