Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,12 @@
|
|||
object VanDerCorput extends App {
|
||||
def compute(n: Int, base: Int = 2) =
|
||||
Iterator.from(0).
|
||||
scanLeft(1)((a, _) => a * base).
|
||||
map(b => (n - 1) / b -> b).
|
||||
takeWhile(_._1 != 0).
|
||||
foldLeft(0d)((a, b) => a + (b._1 % base).toDouble / b._2 / base)
|
||||
|
||||
val n = scala.io.StdIn.readInt
|
||||
val b = scala.io.StdIn.readInt
|
||||
(1 to n).foreach(x => println(compute(x, b)))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue