RosettaCodeData/Task/Time-a-function/FreeBASIC/time-a-function.freebasic

20 lines
475 B
Plaintext

' FB 1.05.0 Win64
Function sumToLimit(limit As UInteger) As UInteger
Dim sum As UInteger = 0
For i As UInteger = 1 To limit
sum += i
Next
Return sum
End Function
Dim As Double start = timer
Dim limit As UInteger = 100000000
Dim result As UInteger = sumToLimit(limit)
Dim ms As UInteger = Int(1000 * (timer - start) + 0.5)
Print "sumToLimit("; Str(limit); ") = "; result
Print "took "; ms; " milliseconds to calculate"
Print
Print "Press any key to quit"
Sleep