File tree Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,9 @@ compile_commands.json
99
1010# swap file from vim
1111** /* .sw *
12+ <<<<<<< HEAD
1213
1314# vscode file
1415.vscode
16+ =======
17+ >>>>>>> refs /remotes /origin /main
Original file line number Diff line number Diff line change 11#include < cstdint>
22#include < type_traits>
3+ <<<<<<< HEAD
34#include < vector>
45
56namespace Discrete {
@@ -26,4 +27,14 @@ public:
2627
2728 }
2829};
29- } // namespace Discrete
30+ } // namespace Discrete
31+ =======
32+
33+ template <typename T, typename Ret = uint64_t >
34+ std::enable_if_t <std::is_arithmetic_v<T>, Ret>
35+ derangement (T n){
36+ if (!n) return 1 ;
37+ if (n==1 ) return 0 ;
38+ return (n-1 )*(derangement (n-1 )+derangement (n-2 ));
39+ }
40+ >>>>>>> refs/remotes/origin/main
Original file line number Diff line number Diff line change 1+ #pragma once
2+ #include < type_traits>
3+
4+ template <typename T>
5+ std::enable_if_t <std::is_arithmetic_v<T>> factorial (T n) {
6+ if (n == 1 ) return 1 ;
7+ return n * factorial (n - 1 );
8+ }
9+
10+ template <typename T>
11+ T permutation (T n){
12+ return factorial<T>(n);
13+ }
You can’t perform that action at this time.
0 commit comments