Microsoft Small Basic

Program Listing: jdw047
'Natham Aguire
'naguirr1@binghamton.edu

TextWindow.WriteLine ("This program will give you the first number in the Fibonacci sequence with a certain amount of digits")

again:
'ask for initial conditions
TextWindow.WriteLine ("How many digits are you looking for?")
digits = TextWindow.ReadNumber()
repeat:
TextWindow.WriteLine ("Do you want to see the sequence up to the number?")
see = TextWindow.Read()
TextWindow.Clear ()

If see = "yes" or see = "no" then
else
textWindow.WriteLine ("you must say 'yes' or 'no'")
Goto repeat
Endif

'set initial value of parameters
initialtime = Clock.Time
percentage = 0
timesaving = 1


'this will set a m-amount of numbers to divide the total length in 28-digits number

m = math.Ceiling (digits/27)
For e = 1 To m
for d =0 to 2
If e=1 And d=0 Then
n[e][d]=1
Else
n[e][d]=0
Endif
Endfor
EndFor

start1:
'this will recognize up to what digit those below are significant figures; the procces will be done up to that digit
'not sure if really needed, but it allows to keep track of the percentage of progress done
For w=m to 1 step -1
If n[w][0] > 0 Then
upper = w
Goto beggin
EndIf
endfor



'this is the beggining of the iterative process
beggin:
'only if you want to see the process
If see = "yes" then
print()
Else
'this will give feedback on the process
percentage = (27*(upper-1) + text.GetLength (n[m][0]))*100/ digits
TextWindow.Clear ()
TextWindow.Write (percentage + "% done")
Endif



'if the number of digits has been reached, this will print the information and will stop the program
If upper = m and (27*(upper-1) + text.GetLength (n[m][0])) = digits then
TextWindow.WriteLine ("")
TextWindow.Write ("The number you are looking for is ")
print ()
finaltime=Clock.Time
TextWindow.WriteLine ("")
TextWindow.Writeline("It took from" + initialtime + " to " + finaltime )
Goto exit
Endif


'this is pretty much a calculator that will operate digit by digit applying the fibonacci sequence
For e = 1 to upper
if 28>text.GetLength (n[e][0]) Then
n[e][2]=n[e][1]
n[e][1]=n[e][0]
n[e][0]=n[e][1]+n[e][2]
EndIf
EndFor

For e = 1 to upper
if text.GetLength (n[e][0])>28 Or text.GetLength (n[e][0])=28 Then
n[e+1][0] = n[e+1][0] + 1
n[e][0] = text.GetSubText (n[e][0],2,27)
EndIf
Endfor

'this will repeat the process if the number of digits has not been reached
Goto start1

exit:

'to repeat the program
goto again


'this is the print sub
Sub print
For y = upper To 1 step-1
TextWindow.Write(n[y][0])
Endfor
TextWindow.Write("/")
EndSub