49 lines
732 B
Plaintext
49 lines
732 B
Plaintext
' version 01-03-2019
|
|
' compile with: fbc -s console
|
|
|
|
#Define max 20000000
|
|
|
|
Dim Shared As UInteger f(max)
|
|
|
|
Sub fusc
|
|
|
|
f(0) = 0
|
|
f(1) = 1
|
|
|
|
For n As UInteger = 2 To max
|
|
If n And 1 Then
|
|
f(n) = f((n -1) \ 2) + f((n +1) \ 2)
|
|
Else
|
|
f(n) = f(n \ 2)
|
|
End If
|
|
Next
|
|
|
|
End Sub
|
|
|
|
' ------=< MAIN >=------
|
|
|
|
Dim As UInteger i, d
|
|
Dim As String fs
|
|
|
|
fusc
|
|
|
|
For i = 0 To 60
|
|
Print f(i); " ";
|
|
Next
|
|
|
|
Print : Print
|
|
Print " Index Value"
|
|
For i = 0 To max
|
|
If f(i) >= d Then
|
|
Print Using "###########," ; i; f(i)
|
|
If d = 0 Then d = 1
|
|
d *= 10
|
|
End If
|
|
Next
|
|
|
|
' empty keyboard buffer
|
|
While Inkey <> "" : Wend
|
|
Print : Print "hit any key to end program"
|
|
Sleep
|
|
End
|