From 3854f4310c0efd4be3f6777b1d0e7f3d498bdf1f Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Tue, 27 Jul 2021 23:11:15 +0000 Subject: [PATCH] clang-format and clang-tidy fixes for 0ec45e33 --- math/check_prime.cpp | 8 ++++---- math/finding_number_of_digits_in_a_number.cpp | 15 +++++++++------ search/floyd_cycle_detection_algo.cpp | 6 ++++-- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/math/check_prime.cpp b/math/check_prime.cpp index d68325d56..3c3ff2b62 100644 --- a/math/check_prime.cpp +++ b/math/check_prime.cpp @@ -22,11 +22,11 @@ template bool is_prime(T num) { bool result = true; if (num <= 1) { - return 0; + return false; } else if (num == 2) { - return 1; + return true; } else if ((num & 1) == 0) { - return 0; + return false; } if (num >= 3) { for (T i = 3; (i * i) <= (num); i = (i + 2)) { @@ -47,7 +47,7 @@ int main() { assert(is_prime(50) == false); assert(is_prime(115249) == true); - int num; + int num = 0; std::cout << "Enter the number to check if it is prime or not" << std::endl; std::cin >> num; bool result = is_prime(num); diff --git a/math/finding_number_of_digits_in_a_number.cpp b/math/finding_number_of_digits_in_a_number.cpp index d4bb95087..5eb5841c5 100644 --- a/math/finding_number_of_digits_in_a_number.cpp +++ b/math/finding_number_of_digits_in_a_number.cpp @@ -2,14 +2,17 @@ * @author [aminos 🇮🇳](https://github.com/amino19) * @file * - * @brief [Program to count digits - * in an integer](https://www.geeksforgeeks.org/program-count-digits-integer-3-different-methods) + * @brief [Program to count digits + * in an + * integer](https://www.geeksforgeeks.org/program-count-digits-integer-3-different-methods) * @details It is a very basic math of finding number of digits in a given * number i.e, we can use it by inputting values whether it can be a - * positive/negative value, let's say: an integer. There is also a second method: - * by using "K = floor(log10(N) + 1)", but it's only applicable for + * positive/negative value, let's say: an integer. There is also a second + * method: by using "K = floor(log10(N) + 1)", but it's only applicable for * numbers (not integers). - * For more details, refer to the [Algorithms-Explanation](https://github.com/TheAlgorithms/Algorithms-Explanation/blob/master/en/Basic%20Math/Finding the number of digits in a number.md) repository. + * For more details, refer to the + * [Algorithms-Explanation](https://github.com/TheAlgorithms/Algorithms-Explanation/blob/master/en/Basic%20Math/Finding + * the number of digits in a number.md) repository. */ #include /// for assert @@ -29,7 +32,7 @@ int main() { // iterate until `n` becomes 0 // remove last digit from `n` in each iteration - // increase `count` by 1 in each iteration + // increase `count` by 1 in each iteration while (n != 0) { // we can also use `n = n / 10` n /= 10; diff --git a/search/floyd_cycle_detection_algo.cpp b/search/floyd_cycle_detection_algo.cpp index ac3d62769..c7dd95aea 100644 --- a/search/floyd_cycle_detection_algo.cpp +++ b/search/floyd_cycle_detection_algo.cpp @@ -35,12 +35,14 @@ namespace cycle_detection { */ template int32_t duplicateNumber(const std::vector &in_arr, const uint32_t &n) { - if (n == 0 || n == 1) { // to find duplicate in an array its size should be atleast 2 + if (n == 0 || + n == 1) { // to find duplicate in an array its size should be atleast 2 return -1; } uint32_t tortoise = in_arr[0]; // variable tortoise is used for the longer // jumps in the array - uint32_t hare = in_arr[0]; // variable hare is used for shorter jumps in the array + uint32_t hare = + in_arr[0]; // variable hare is used for shorter jumps in the array do { tortoise = in_arr[tortoise]; hare = in_arr[in_arr[hare]];