Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
48
Task/Fusc-sequence/FreeBASIC/fusc-sequence.basic
Normal file
48
Task/Fusc-sequence/FreeBASIC/fusc-sequence.basic
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
' 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue