diff --git a/scripts/fibonacci.rhai b/scripts/fibonacci.rhai index 3455c5f6..14a35d5e 100644 --- a/scripts/fibonacci.rhai +++ b/scripts/fibonacci.rhai @@ -1,7 +1,7 @@ // This script calculates the n-th Fibonacci number using a really dumb algorithm // to test the speed of the scripting engine. -const target = 30; +const target = 28; fn fib(n) { if n < 2 { @@ -11,16 +11,20 @@ fn fib(n) { } } +print("Running Fibonacci(28) x 5 times..."); print("Ready... Go!"); +let result; let now = timestamp(); -let result = fib(target); +for n in range(0, 5) { + result = fib(target); +} print("Finished. Run time = " + now.elapsed + " seconds."); print("Fibonacci number #" + target + " = " + result); -if result != 832_040 { - print("The answer is WRONG! Should be 832,040!"); -} \ No newline at end of file +if result != 317_811 { + print("The answer is WRONG! Should be 317,811!"); +}