mirror of
https://github.com/cubixle/codekata-golang.git
synced 2026-04-30 13:28:42 +01:00
23: non-abundant sums
This commit is contained in:
@@ -5,7 +5,7 @@ import "fmt"
|
||||
func main() {
|
||||
n := 20
|
||||
for {
|
||||
if IsDivisibleFor1to20(n) {
|
||||
if IsDivisible(1, 20, n) {
|
||||
fmt.Println("evenly divisible by all of the numbers from 1 to 20:", n)
|
||||
return
|
||||
}
|
||||
@@ -13,8 +13,8 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
func IsDivisibleFor1to20(n int) bool {
|
||||
for i := 1; i <= 20; i++ {
|
||||
func IsDivisible(start, end, n int) bool {
|
||||
for i := start; i <= end; i++ {
|
||||
if n%i != 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user