From 957a05bd0cd7e21017e13f57be3998ae1cdd7b73 Mon Sep 17 00:00:00 2001 From: Panquesito7 Date: Tue, 23 Jun 2020 17:39:29 -0500 Subject: [PATCH] fix: Convert global variables to local --- math/fibonacci_fast.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/math/fibonacci_fast.cpp b/math/fibonacci_fast.cpp index 80e9108ea..dba8b9dc0 100644 --- a/math/fibonacci_fast.cpp +++ b/math/fibonacci_fast.cpp @@ -19,15 +19,15 @@ #include #include -/** maximum number that can be computed - The result after 93 cannot be stored - * in a `uint64_t` data type. */ -const uint64_t MAX = 93; - -/** Array of computed fibonacci numbers */ -uint64_t numbers[MAX] = {0}; - /** Algorithm */ uint64_t fib(uint64_t n) { + // maximum number that can be computed - The result after 93 cannot be stored + // in a `uint64_t` data type. + static const uint64_t MAX = 93; + + // Array of computed fibonacci numbers */ + static uint64_t numbers[MAX] = {0}; + if (n == 0) return 0; if (n == 1 || n == 2)