File tree Expand file tree Collapse file tree 1 file changed +2
-3
lines changed Expand file tree Collapse file tree 1 file changed +2
-3
lines changed Original file line number Diff line number Diff line change 13
13
14
14
#include < iostream>
15
15
#include < cassert> // For test cases
16
- #include < cstdint> // For uint64_t
17
16
#include < array>
18
17
// / Array to store computed factorials for memoization
19
- std::array<uint64_t , 1000 > memo{0 };
18
+ std::array<__uint128_t , 1000 > memo{0 };
20
19
21
20
/* *
22
21
* @brief Computes the factorial of a non-negative integer using recursion and memoization.
23
22
* @param n The integer whose factorial is to be computed
24
23
* @returns The factorial of n
25
24
*/
26
- long long fact_rec (int n) {
25
+ __uint128_t fact_rec (__uint128_t n) {
27
26
if (n == 0 ) return 1 ; // Base case: 0! = 1
28
27
if (memo[n] != 0 ) return memo[n]; // Return already computed value
29
28
memo[n] = n * fact_rec (n - 1 ); // Store and return the computed value
You can’t perform that action at this time.
0 commit comments