mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-04-05 11:40:46 +08:00
bug fix - no function return and invalid for loop termination check
This commit is contained in:
@@ -11,10 +11,11 @@
|
||||
/// Compute double factorial using iterative method
|
||||
uint64_t double_factorial_iterative(uint64_t n) {
|
||||
uint64_t res = 1;
|
||||
for (uint64_t i = n; i >= 0; i -= 2) {
|
||||
for (uint64_t i = n;; i -= 2) {
|
||||
if (i == 0 || i == 1) return res;
|
||||
res *= i;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/// Compute double factorial using resursive method.
|
||||
|
||||
Reference in New Issue
Block a user