From 44f68e9a2e50275fce0d6a3e23ed5f15585c1ff5 Mon Sep 17 00:00:00 2001 From: Krishna Vedala Date: Wed, 27 May 2020 12:54:42 -0400 Subject: [PATCH] bug fix - no function return and invalid for loop termination check --- math/double_factorial.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/math/double_factorial.cpp b/math/double_factorial.cpp index 2b28a5d5a..73a3d344a 100644 --- a/math/double_factorial.cpp +++ b/math/double_factorial.cpp @@ -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.