cpp-project-template 0.0.1.0
C++ Project Template
Loading...
Searching...
No Matches
tutorial_1.hpp
Go to the documentation of this file.
1
10
11
12#ifndef TUT1_HPP
13#define TUT1_HPP
14
15#include <concepts> // std::integral
16
20namespace tut1
21{
22
29constexpr std::integral auto factorial(std::integral auto n)
30{
31 std::integral auto res = 1;
32 for (auto i = 2; i <= n; ++i)
33 {
34 res *= i;
35 }
36 return res;
37}
38
39} // namespace tut1
40
41#endif
The namespace for this tutorial.
Definition tutorial_1.hpp:21
constexpr std::integral auto factorial(std::integral auto n)
Calculate the factorial of a given integral number.
Definition tutorial_1.hpp:29