From febfe8f07b428dacdd1c06e186bd77bb16774be8 Mon Sep 17 00:00:00 2001 From: a Date: Fri, 7 Oct 2022 00:19:35 -0700 Subject: [PATCH] Fix issue #21 This issue was caused by trying to factor 0, which resulted in a zero-length array where it was not expected --- src/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/script.js b/src/script.js index 56e2d8ef..5531eaa6 100644 --- a/src/script.js +++ b/src/script.js @@ -445,7 +445,7 @@ $(document).ready(function () { let randomValue = Math.random(); // ab = (a - c)(b + c) + c (b - a + c), where c is any random positive number - if (n < 100 && (n == 2 || !isPrime(n)) && randomValue < 0.25) { + if (parseInt(n) !== 0 && n < 100 && (n == 2 || !isPrime(n)) && randomValue < 0.25) { let factors = getFactors(parseInt(n)); let randomIndex = Math.floor(Math.random() * factors.length); let a = factors[randomIndex];