fun main(args: Array) { val totalAttempts: Int = 256*256*256 var successfulAttempts: Int = 0 for (a in 0..255) { for (b in 0..255) { for (c in 0..255) { if (a + b + c > 300) { successfulAttempts++ } } } } println("Iterations: $totalAttempts") println("Valid sums: $successfulAttempts") println("Probability: ${successfulAttempts.toFloat() / totalAttempts.toFloat()}") }