Check scripts for calculation errors.

This commit is contained in:
Stephen Chung 2020-05-13 11:56:48 +08:00
parent 996a54279c
commit c37a2cc886
2 changed files with 11 additions and 3 deletions

View File

@ -3,8 +3,6 @@
const target = 30;
let now = timestamp();
fn fib(n) {
if n < 2 {
n
@ -15,8 +13,14 @@ fn fib(n) {
print("Ready... Go!");
let now = timestamp();
let result = fib(target);
print("Finished. Run time = " + now.elapsed() + " seconds.");
print("Fibonacci number #" + target + " = " + result);
print("Finished. Run time = " + now.elapsed() + " seconds.");
if result != 832_040 {
print("The answer is WRONG! Should be 832,040!");
}

View File

@ -27,3 +27,7 @@ for p in range(2, MAX_NUMBER_TO_CHECK) {
print("Total " + total_primes_found + " primes <= " + MAX_NUMBER_TO_CHECK);
print("Run time = " + now.elapsed() + " seconds.");
if total_primes_found != 9_592 {
print("The answer is WRONG! Should be 9,592!");
}