Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
16
Task/Van-der-Corput-sequence/Nim/van-der-corput-sequence.nim
Normal file
16
Task/Van-der-Corput-sequence/Nim/van-der-corput-sequence.nim
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import rationals, strutils, sugar
|
||||
|
||||
type Fract = Rational[int]
|
||||
|
||||
proc corput(n: int; base: Positive): Fract =
|
||||
result = 0.toRational
|
||||
var b = 1 // base
|
||||
var n = n
|
||||
while n != 0:
|
||||
result += n mod base * b
|
||||
n = n div base
|
||||
b /= base
|
||||
|
||||
for base in 2..5:
|
||||
let list = collect(newSeq, for n in 1..10: corput(n, base))
|
||||
echo "Base $#: ".format(base), list.join(" ")
|
||||
Loading…
Add table
Add a link
Reference in a new issue