Skip to content

Commit 2d49283

Browse files
heysujalPanquesito7github-actions[bot]
authored
feat: update CMake version to 3.26.4 (#2486)
* update cmake version * clang-format and clang-tidy fixes for 402c562 --------- Co-authored-by: David Leal <[email protected]> Co-authored-by: github-actions[bot] <[email protected]>
1 parent d7a9869 commit 2d49283

File tree

4 files changed

+42
-39
lines changed

4 files changed

+42
-39
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.9)
1+
cmake_minimum_required(VERSION 3.26.4)
22
project(Algorithms_in_C++
33
LANGUAGES CXX
44
VERSION 1.0.0

math/check_factorial.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @file
3-
* @brief A simple program to check if the given number is a [factorial](https://en.wikipedia.org/wiki/Factorial) of some
4-
* number or not.
3+
* @brief A simple program to check if the given number is a
4+
* [factorial](https://en.wikipedia.org/wiki/Factorial) of some number or not.
55
*
66
* @details A factorial number is the sum of k! where any value of k is a
77
* positive integer. https://www.mathsisfun.com/numbers/factorial.html

math/check_prime.cpp

+34-33
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
/**
22
* @file
33
* @brief
4-
* A simple program to check if the given number is [Prime](https://en.wikipedia.org/wiki/Primality_test) or not.
4+
* A simple program to check if the given number is
5+
* [Prime](https://en.wikipedia.org/wiki/Primality_test) or not.
56
* @details
6-
* A prime number is any number that can be divided only by itself and 1. It must
7-
* be positive and a whole number, therefore any prime number is part of the
8-
* set of natural numbers. The majority of prime numbers are even numbers, with
9-
* the exception of 2. This algorithm finds prime numbers using this information.
10-
* additional ways to solve the prime check problem:
7+
* A prime number is any number that can be divided only by itself and 1. It
8+
* must be positive and a whole number, therefore any prime number is part of
9+
* the set of natural numbers. The majority of prime numbers are even numbers,
10+
* with the exception of 2. This algorithm finds prime numbers using this
11+
* information. additional ways to solve the prime check problem:
1112
* https://cp-algorithms.com/algebra/primality_tests.html#practice-problems
1213
* @author [Omkar Langhe](https://github.com/omkarlanghe)
1314
* @author [ewd00010](https://github.com/ewd00010)
@@ -21,37 +22,37 @@
2122
* @namespace
2223
*/
2324
namespace math {
24-
/**
25-
* @brief Function to check if the given number is prime or not.
26-
* @param num number to be checked.
27-
* @return true if number is a prime
28-
* @return false if number is not a prime.
25+
/**
26+
* @brief Function to check if the given number is prime or not.
27+
* @param num number to be checked.
28+
* @return true if number is a prime
29+
* @return false if number is not a prime.
30+
*/
31+
bool is_prime(int64_t num) {
32+
/*!
33+
* Reduce all possibilities of a number which cannot be prime with the first
34+
* 3 if, else if conditionals. Example: Since no even number, except 2 can
35+
* be a prime number and the next prime we find after our checks is 5,
36+
* we will start the for loop with i = 5. then for each loop we increment
37+
* i by +6 and check if i or i+2 is a factor of the number; if it's a factor
38+
* then we will return false. otherwise, true will be returned after the
39+
* loop terminates at the terminating condition which is i*i <= num
2940
*/
30-
bool is_prime(int64_t num) {
31-
/*!
32-
* Reduce all possibilities of a number which cannot be prime with the first
33-
* 3 if, else if conditionals. Example: Since no even number, except 2 can
34-
* be a prime number and the next prime we find after our checks is 5,
35-
* we will start the for loop with i = 5. then for each loop we increment
36-
* i by +6 and check if i or i+2 is a factor of the number; if it's a factor
37-
* then we will return false. otherwise, true will be returned after the
38-
* loop terminates at the terminating condition which is i*i <= num
39-
*/
40-
if (num <= 1) {
41-
return false;
42-
} else if (num == 2 || num == 3) {
43-
return true;
44-
} else if (num % 2 == 0 || num % 3 == 0) {
45-
return false;
46-
} else {
47-
for (int64_t i = 5; i * i <= num; i = i + 6) {
48-
if (num % i == 0 || num % (i + 2) == 0) {
49-
return false;
50-
}
41+
if (num <= 1) {
42+
return false;
43+
} else if (num == 2 || num == 3) {
44+
return true;
45+
} else if (num % 2 == 0 || num % 3 == 0) {
46+
return false;
47+
} else {
48+
for (int64_t i = 5; i * i <= num; i = i + 6) {
49+
if (num % i == 0 || num % (i + 2) == 0) {
50+
return false;
5151
}
5252
}
53-
return true;
5453
}
54+
return true;
55+
}
5556
} // namespace math
5657

5758
/**

strings/boyer_moore.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
/**
22
* @file
33
* @brief
4-
* The [Boyer–Moore](https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_string-search_algorithm) algorithm searches for occurrences of pattern P in text T by
5-
* performing explicit character comparisons at different alignments. Instead of
6-
* a brute-force search of all alignments (of which there are n - m + 1),
4+
* The
5+
* [Boyer–Moore](https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_string-search_algorithm)
6+
* algorithm searches for occurrences of pattern P in text T by performing
7+
* explicit character comparisons at different alignments. Instead of a
8+
* brute-force search of all alignments (of which there are n - m + 1),
79
* Boyer–Moore uses information gained by preprocessing P to skip as many
810
* alignments as possible.
911
*

0 commit comments

Comments
 (0)