mirror of
https://hub.njuu.cf/TheAlgorithms/C-Plus-Plus.git
synced 2023-10-11 13:05:55 +08:00
fix: Convert global variables to local
This commit is contained in:
parent
a6c3667f30
commit
957a05bd0c
@ -19,15 +19,15 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
/** 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 */
|
/** Algorithm */
|
||||||
uint64_t fib(uint64_t n) {
|
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)
|
if (n == 0)
|
||||||
return 0;
|
return 0;
|
||||||
if (n == 1 || n == 2)
|
if (n == 1 || n == 2)
|
||||||
|
Loading…
Reference in New Issue
Block a user