##PowerShell, 52 bytes
PowerShell, 52 bytes
while($a++-$args[0]){"0."+-join"$a"["$a".Length..0]}
A little longer than I'd like, but uses a couple of neat tricks.
The while
loop is obvious, but the conditional is a little tricky - we have $a
(which starts as $null
when first referenced) and then subtract our input number $args[0]
. In PowerShell, math operations on $null
treat it as zero, so for input 20
for example this will result in -20
. Since any non-zero number is $true
, the loop conditional will be $true
right up until $a
equals our input number (at which point the subtraction will equal 0
or $false
). The trick comes from the post-increment ++
, which doesn't execute until after the subtraction is calculated, so handling input of 1
will correctly output 0.1
and then stop the loop on the next iteration.
Each time in the loop, we just create a string literal which gets left on the pipeline and output accordingly. We construct this from "0."
concatenated with the result of the unary -join
operator that has acted on the char-array created from taking the string "$a"
backwards (by indexing via the range "$a".length..0
).
Test Runs
PS C:\Tools\Scripts\golfing> .\van-der-corput-sequence.ps1 1
0.1
PS C:\Tools\Scripts\golfing> .\van-der-corput-sequence.ps1 20
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
0.01
0.11
0.21
0.31
0.41
0.51
0.61
0.71
0.81
0.91
0.02