25 lines
386 B
Text
25 lines
386 B
Text
func properDivs(n) {
|
|
if n == 1 {
|
|
yield break
|
|
}
|
|
for x in 1..<n {
|
|
if n % x == 0 {
|
|
yield x
|
|
}
|
|
}
|
|
}
|
|
|
|
for i in 1..10 {
|
|
print("\(i): \(properDivs(i).ToArray())")
|
|
}
|
|
|
|
var (num, max) = (0,0)
|
|
|
|
for i in 1..20000 {
|
|
let count = properDivs(i).Length()
|
|
if count > max {
|
|
set (num, max) = (i, count)
|
|
}
|
|
}
|
|
|
|
print("\(num): \(max)")
|