mirror of
https://github.com/cubixle/codekata-golang.git
synced 2026-04-24 20:04:43 +01:00
24 lines
317 B
Go
24 lines
317 B
Go
package main
|
|
|
|
import "fmt"
|
|
|
|
func main() {
|
|
n := 20
|
|
for {
|
|
if IsDivisible(1, 20, n) {
|
|
fmt.Println("evenly divisible by all of the numbers from 1 to 20:", n)
|
|
return
|
|
}
|
|
n++
|
|
}
|
|
}
|
|
|
|
func IsDivisible(start, end, n int) bool {
|
|
for i := start; i <= end; i++ {
|
|
if n%i != 0 {
|
|
return false
|
|
}
|
|
}
|
|
return true
|
|
}
|