mirror of
https://hub.njuu.cf/TheAlgorithms/C-Plus-Plus.git
synced 2023-10-11 13:05:55 +08:00
bug fix - no function return and invalid for loop termination check
This commit is contained in:
parent
4134c16f42
commit
44f68e9a2e
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user