TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
Loading...
Searching...
No Matches
sum_of_binomial_coefficient.cpp
Go to the documentation of this file.
1
12#include <cassert>
13#include <cstdint>
14#include <iostream>
15
20namespace math {
21
27uint64_t binomialCoeffSum(uint64_t n) {
28 // Calculating 2^n
29 return (1 << n);
30}
31} // namespace math
32
38static void test() {
39 int test_case_1 = math::binomialCoeffSum(2);
40 assert(test_case_1 == 4);
41 std::cout << "Test_case_1 Passed!" << std::endl;
42
43 int test_case_2 = math::binomialCoeffSum(3);
44 assert(test_case_2 == 8);
45 std::cout << "Test_case_2 Passed!" << std::endl;
46
47 int test_case_3 = math::binomialCoeffSum(4);
48 assert(test_case_3 == 16);
49 std::cout << "Test_case_3 Passed!" << std::endl;
50
51 int test_case_4 = math::binomialCoeffSum(5);
52 assert(test_case_4 == 32);
53 std::cout << "Test_case_4 Passed!" << std::endl;
54
55 int test_case_5 = math::binomialCoeffSum(7);
56 assert(test_case_5 == 128);
57 std::cout << "Test_case_5 Passed!" << std::endl;
58}
59
64int main() {
65 test(); // execute the tests
66 return 0;
67}
for assert
uint64_t binomialCoeffSum(uint64_t n)
static void test()
int main()
Main function.