blob: c61b3e53d44510d20acea7e9394a5c16d3fde9b8 (
plain) (
tree)
|
|
import scala.math.random
import spark._
import SparkContext._
object LocalPi {
def main(args: Array[String]) {
var count = 0
for (i <- 1 to 100000) {
val x = random * 2 - 1
val y = random * 2 - 1
if (x*x + y*y < 1) count += 1
}
println("Pi is roughly " + 4 * count / 100000.0)
}
}
|