RosettaCodeData/Task/General-FizzBuzz/FreeBASIC/general-fizzbuzz.basic

60 lines
1.2 KiB
Plaintext

' version 01-03-2018
' compile with: fbc -s console
Dim As UInteger f(), factor, c, i, n
Dim As Integer max
Dim As String w(), word
Dim As boolean flag
Do
Input "Enter maximum number, if number < 1 then the program wil end ", max
If max < 1 Then Exit Do
Print
While c = 0 Or c > max
Input "Total number of factors ", c
Wend
c -= 1
ReDim f(c), w(c)
Print
For i = 0 To c
Input "Enter factor and word, separated by a comma ", factor, word
f(i) = factor
w(i) = word
Next
While flag = FALSE
flag = TRUE
For n = 0 To c-1
For i = 1 To c
If f(n) > f(i) Then
flag = FALSE
Swap f(n), f(i)
Swap w(n), w(i)
End If
Next
Next
Wend
For n = 1 To max
flag = FALSE
For i = 0 To c
If n Mod f(i) = 0 Then
flag = TRUE
Print w(i);
End If
Next
Print IIf(flag , "", Str(n))
Next
Exit Do
Loop
' empty keyboard buffer
While Inkey <> "" : Wend
Print : Print "hit any key to end program"
Sleep
End