<std::
size_tn>
55 returnstd::all_of(a.begin(), a.end(), [](
intx) { return x == 0; });
63template<std::
size_tn>
64int gcd(
conststd::array<int, n> &a) {
71 intresult = std::abs(a[0]);
72 for(std::size_t i = 1; i < n; ++i) {
73result =
gcd_two(result, std::abs(a[i]));
88std::array<int, 1> array_1 = {0};
89std::array<int, 1> array_2 = {1};
90std::array<int, 2> array_3 = {0, 2};
91std::array<int, 3> array_4 = {-60, 24, 18};
92std::array<int, 4> array_5 = {100, -100, -100, 200};
93std::array<int, 5> array_6 = {0, 0, 0, 0, 0};
94std::array<int, 7> array_7 = {10350, -24150, 0, 17250, 37950, -127650, 51750};
95std::array<int, 7> array_8 = {9500000, -12121200, 0, 4444, 0, 0, 123456789};
int gcd(const std::array< int, n > &a)
Main program to compute GCD using the Euclidean algorithm.
int gcd_two(int x, int y)
Function to compute GCD of 2 numbers x and y.
bool check_all_zeros(const std::array< int, n > &a)
Function to check if all elements in the array are 0.
static void test()
Self-test implementation.
int main()
Main function.
Compute GCD of numbers in an array.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4