Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
19
Task/Super-d-numbers/Nim/super-d-numbers.nim
Normal file
19
Task/Super-d-numbers/Nim/super-d-numbers.nim
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import sequtils, strutils, times
|
||||
import bignum
|
||||
|
||||
iterator superDNumbers(d, maxCount: Positive): Natural =
|
||||
var count = 0
|
||||
var n = 2
|
||||
let e = culong(d) # Bignum ^ requires a culong as exponent.
|
||||
let pattern = repeat(chr(d + ord('0')), d)
|
||||
while count != maxCount:
|
||||
if pattern in $(d * n ^ e):
|
||||
yield n
|
||||
inc count
|
||||
inc n, 1
|
||||
|
||||
let t0 = getTime()
|
||||
for d in 2..9:
|
||||
echo "First 10 super-$# numbers:".format(d)
|
||||
echo toSeq(superDNumbers(d, 10)).join(" ")
|
||||
echo "Time: ", getTime() - t0
|
||||
Loading…
Add table
Add a link
Reference in a new issue