Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/marian-nmt/intgemm.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateusz Chudyk <mateuszchudyk@gmail.com>2019-06-19 15:19:56 +0300
committerMateusz Chudyk <mateuszchudyk@gmail.com>2019-06-21 12:59:39 +0300
commit66bf6f64458b0091d497d8235f13f09ca07437ee (patch)
tree17973231bfd93e4838d0894daab0f00d06b328db
parent5484761340d17769da4502d4f74c3b261736a88d (diff)
Add constexpr factorial
-rw-r--r--utils.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/utils.h b/utils.h
index a403995..6e095e3 100644
--- a/utils.h
+++ b/utils.h
@@ -49,4 +49,11 @@ constexpr subtuple_t<Tuple, Indices...> make_subtuple(const Tuple& tuple, sequen
return std::make_tuple(std::get<Indices>(tuple)...);
}
+/*
+ * Factorial
+ */
+constexpr unsigned long long factorial(unsigned n) {
+ return n <= 1 ? 1 : n * factorial(n - 1);
+}
+
}