RosettaCodeData/Task/Van-der-Corput-sequence/FreeBASIC/van-der-corput-sequence.basic

43 lines
760 B
Plaintext

' version 03-12-2016
' compile with: fbc -s console
Function num_base(number As ULongInt, _base_ As UInteger) As String
If _base_ > 9 Then
Print "base not handled by function"
Sleep 5000
Return ""
End If
Dim As ULongInt n
Dim As String ans
While number <> 0
n = number Mod _base_
ans = Str(n) + ans
number = number \ _base_
Wend
If ans = "" Then ans = "0"
Return "." + ans
End Function
' ------=< MAIN >=------
Dim As ULong k, l
For k = 2 To 5
Print "Base = "; k
For l = 0 To 12
Print left(num_base(l, k) + " ",6);
Next
Print : print
Next
' empty keyboard buffer
While Inkey <> "" : Wend
Print : Print "hit any key to end program"
Sleep
End