Initial commit
This commit is contained in:
3
Go/code_cycle/go.mod
Normal file
3
Go/code_cycle/go.mod
Normal file
@@ -0,0 +1,3 @@
|
||||
module example/hello
|
||||
|
||||
go 1.23
|
||||
24
Go/code_cycle/main.go
Normal file
24
Go/code_cycle/main.go
Normal file
@@ -0,0 +1,24 @@
|
||||
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)))
|
||||
}
|
||||
Reference in New Issue
Block a user