18 lines
499 B
Kotlin
18 lines
499 B
Kotlin
fun main(args: Array<String>) {
|
|
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()}")
|
|
} |