Basic-benchmark-experiment/Go/code_cycle/main.go

25 lines
452 B
Go

package main
import "fmt"
func main() {
var (
iterations int = 256 * 256 * 256
successes_amount int = 0
)
for a := 0; a < 256; a++ {
for b := 0; b < 256; b++ {
for c := 0; c < 256; c++ {
if a+b+c > 300 {
successes_amount++
}
}
}
}
fmt.Printf("Iterations: %v\n", iterations)
fmt.Printf("Valid sums: %v\n", successes_amount)
fmt.Printf("Probability: %v\n", (float32(successes_amount) / float32(iterations)))
}