[SPARK-4033][Examples]Input of the SparkPi  too big causes the emption exception

If input of the SparkPi args is larger than the 25000, the integer 'n' inside the code will be overflow, and may be a negative number.
And it causes  the (0 until n) Seq as an empty seq, then doing the action 'reduce'  will throw the UnsupportedOperationException("empty collection").

The max size of the input of sc.parallelize is Int.MaxValue - 1, not the Int.MaxValue.
I think you need to supply a new slices number if slices is too large. 
 something like math.min(slices, n / 100000).

So, a better solution may be :

    val realSlices = math.min(slices, Int.MaxValue/100000)
    val n = 100000 * realSlices