RosettaCodeData/Task/Babbage-problem/Go/babbage-problem.go
2023-07-01 13:44:08 -04:00

20 lines
325 B
Go

package main
import "fmt"
func main() {
const (
target = 269696
modulus = 1000000
)
for n := 1; ; n++ { // Repeat with n=1, n=2, n=3, ...
square := n * n
ending := square % modulus
if ending == target {
fmt.Println("The smallest number whose square ends with",
target, "is", n,
)
return
}
}
}