RosettaCodeData/Task/Van-der-Corput-sequence/XPL0/van-der-corput-sequence.xpl0

17 lines
348 B
Plaintext

include c:\cxpl\codes; \intrinsic 'code' declarations
func real VdC(N); \Return Nth term of van der Corput sequence in base 2
int N;
real V, U;
[V:= 0.0; U:= 0.5;
repeat N:= N/2;
if rem(0) then V:= V+U;
U:= U/2.0;
until N=0;
return V;
];
int N;
for N:= 0 to 10-1 do
[IntOut(0, N); RlOut(0, VdC(N)); CrLf(0)]