Anonymous user
Harshad or Niven series: Difference between revisions
Updated to compile with Nim 1.4. Simplified the code.
No edit summary |
(Updated to compile with Nim 1.4. Simplified the code.) |
||
Line 2,228:
=={{header|Nim}}==
▲proc slice[T](iter: iterator(): T {.closure.}, sl): seq[T] =
var i = 0
for n in iter():
if i > sl.b: break
if i >= sl.a: result.add(n)▼
▲ result.add(n)
inc i
▲iterator harshad(): int64 {.closure.} =
▲ for n in 1 .. < int64.high:
var sum = 0
for ch in
sum +=
if n mod sum == 0:
yield n
echo harshad.slice 0 ..
for n in harshad():
if n > 1000:
|