Change fibonacci sample to run 5 times.
This commit is contained in:
parent
35394e170a
commit
42fff105ea
@ -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!");
|
||||
}
|
||||
if result != 317_811 {
|
||||
print("The answer is WRONG! Should be 317,811!");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user