TheAlgorithms-C-Plus-Plus/math
ewd00010 e3f0551f98
[fix/docs]: fit check_amicable_pair.cpp to guidelines (#2465)
* Quality of life

FIX:  initlized sum to 1 instead of adding it before return
CHORE: cleaned documentation aswell as adding new documentation, namespace math added

* Update math/check_amicable_pair.cpp

Co-authored-by: realstealthninja <68815218+realstealthninja@users.noreply.github.com>

* Update math/check_amicable_pair.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* Update math/check_amicable_pair.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* Update math/check_amicable_pair.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* clang-format and clang-tidy fixes for bc87fea5

* clang-format and clang-tidy fixes for 0a19d1ad

---------

Co-authored-by: realstealthninja <68815218+realstealthninja@users.noreply.github.com>
Co-authored-by: David Leal <halfpacho@gmail.com>
Co-authored-by: github-actions[bot] <github-actions@users.noreply.github.com>
2023-06-23 14:06:42 -06:00
..
aliquot_sum.cpp [fix/docs]: fit armstrong_number.cpp to guidelines (#2457) 2023-06-20 16:00:41 -06:00
approximate_pi.cpp feat: add approximate_pi.cpp file/algorithm (#1860) 2022-01-19 09:29:50 -06:00
area.cpp feat: Reworked/updated sorting/selection_sort.cpp. (#1613) 2021-10-25 13:17:33 -05:00
armstrong_number.cpp [fix/docs]: fit check_amicable_pair.cpp to guidelines (#2465) 2023-06-23 14:06:42 -06:00
binary_exponent.cpp Major rework to improve code quality and add automation checks (#805) 2020-06-19 21:34:56 +05:30
binomial_calculate.cpp feat: add program to calculate binomial coefficients (#1448) 2021-02-23 00:51:58 +05:30
check_amicable_pair.cpp [fix/docs]: fit check_amicable_pair.cpp to guidelines (#2465) 2023-06-23 14:06:42 -06:00
check_factorial.cpp feat: update CMake version to 3.26.4 (#2486) 2023-06-16 16:08:45 -06:00
check_prime.cpp feat: update CMake version to 3.26.4 (#2486) 2023-06-16 16:08:45 -06:00
CMakeLists.txt Major rework to improve code quality and add automation checks (#805) 2020-06-19 21:34:56 +05:30
complex_numbers.cpp formatting source-code for 247301c5b5 2020-07-02 12:48:35 +00:00
double_factorial.cpp formatting source-code for e1b1c71e7c 2020-06-25 18:41:27 +00:00
eratosthenes.cpp feat: add Sieve of Eratosthenes (originally by @thechubbypanda) (#2442) 2023-03-29 14:24:13 -06:00
eulers_totient_function.cpp fix: fit euler's totient to the contribution guidelines (#2447) 2023-04-28 13:56:52 -06:00
extended_euclid_algorithm.cpp Major rework to improve code quality and add automation checks (#805) 2020-06-19 21:34:56 +05:30
factorial.cpp Major rework to improve code quality and add automation checks (#805) 2020-06-19 21:34:56 +05:30
fast_power.cpp Major rework to improve code quality and add automation checks (#805) 2020-06-19 21:34:56 +05:30
fibonacci_fast.cpp formatting source-code for c7ff9d66f1 2020-06-24 17:14:57 +00:00
fibonacci_large.cpp Major rework to improve code quality and add automation checks (#805) 2020-06-19 21:34:56 +05:30
fibonacci_matrix_exponentiation.cpp Nth fibonacci number using matrix exponentiation (#1215) 2021-02-05 15:12:13 +05:30
fibonacci_sum.cpp feat: Add ncr mod p code (#1325) 2020-11-22 23:05:01 +05:30
fibonacci.cpp fix: math/fibonacci linter warnings. (#1047) 2020-08-25 18:56:49 -05:00
finding_number_of_digits_in_a_number.cpp feat: added log code for counting digits (#2234) 2023-04-14 12:40:14 -06:00
gcd_iterative_euclidean.cpp Major rework to improve code quality and add automation checks (#805) 2020-06-19 21:34:56 +05:30
gcd_of_n_numbers.cpp Major rework to improve code quality and add automation checks (#805) 2020-06-19 21:34:56 +05:30
gcd_recursive_euclidean.cpp Major rework to improve code quality and add automation checks (#805) 2020-06-19 21:34:56 +05:30
integral_approximation2.cpp feat: Reworked/updated sorting/selection_sort.cpp. (#1613) 2021-10-25 13:17:33 -05:00
integral_approximation.cpp feat: added integral approximation algorithm (#1485) 2021-04-22 22:11:44 +05:30
inv_sqrt.cpp feat: Add inverse inverse root functions (#1570) 2021-09-01 11:20:01 -05:00
large_factorial.cpp Major rework to improve code quality and add automation checks (#805) 2020-06-19 21:34:56 +05:30
large_number.h make multiplication 64-bit 2020-06-22 16:21:57 -04:00
largest_power.cpp feat: largest_power (#1406) 2020-11-25 04:18:50 -05:00
lcm_sum.cpp feat: Add ncr mod p code (#1325) 2020-11-22 23:05:01 +05:30
least_common_multiple.cpp fix: Integer overflow of least_common_multiple. (#970) 2020-07-22 08:01:06 -04:00
linear_recurrence_matrix.cpp feat: Solving linear recurrence using Matrix Exponentiation (with examples). (#1463) 2021-03-17 23:57:51 +05:30
magic_number.cpp Update math/magic_number.cpp 2020-10-27 06:33:29 +05:30
miller_rabin.cpp formatting source-code for a48d05fb62 2020-06-21 17:42:09 +00:00
modular_division.cpp clang-format and clang-tidy fixes for 7293e15a 2021-01-18 10:45:57 +00:00
modular_exponentiation.cpp feat: Add modular_exponentiation.cpp (#1276) 2020-10-30 01:52:32 +05:30
modular_inverse_fermat_little_theorem.cpp Major rework to improve code quality and add automation checks (#805) 2020-06-19 21:34:56 +05:30
modular_inverse_simple.cpp feat: add modular_inverse_simple (#1937) 2022-06-09 10:27:12 -05:00
n_bonacci.cpp fix: cover the cases n == 0 and m < n in N_bonacci (#2468) 2023-05-30 20:48:05 -06:00
n_choose_r.cpp feat: Add ncr mod p code (#1325) 2020-11-22 23:05:01 +05:30
ncr_modulo_p.cpp feat: Add ncr mod p code (#1325) 2020-11-22 23:05:01 +05:30
number_of_positive_divisors.cpp fix, test: simplification and tests for number_of_positive_divisors (#975) 2020-07-24 22:59:49 -04:00
perimeter.cpp feat: add perimeter.cpp (#1897) 2022-02-02 11:02:02 +05:30
power_for_huge_numbers.cpp Major rework to improve code quality and add automation checks (#805) 2020-06-19 21:34:56 +05:30
power_of_two.cpp fix: power_of_two algorithm redundant conditional 'else' (#1936) 2022-02-10 10:51:06 -06:00
prime_factorization.cpp Major rework to improve code quality and add automation checks (#805) 2020-06-19 21:34:56 +05:30
prime_numbers.cpp fix: rewrite prime numbers using linear sieve (#1810) 2021-10-31 17:47:16 -06:00
primes_up_to_billion.cpp fix: integer overflow due to multiplication fixed (#886) 2020-06-23 23:50:45 +05:30
quadratic_equations_complex_numbers.cpp feat: add Quadratic equations complex numbers (#2451) 2023-04-28 13:53:19 -06:00
README.md Major rework to improve code quality and add automation checks (#805) 2020-06-19 21:34:56 +05:30
realtime_stats.cpp fix: Various LGTM fixes 2020-06-23 15:13:28 -05:00
sieve_of_eratosthenes.cpp fix, test: Refactor of sieve_of_eratosthenes (#969) 2020-07-23 07:50:38 -04:00
sqrt_double.cpp Major rework to improve code quality and add automation checks (#805) 2020-06-19 21:34:56 +05:30
string_fibonacci.cpp Major rework to improve code quality and add automation checks (#805) 2020-06-19 21:34:56 +05:30
sum_of_binomial_coefficient.cpp feat: Add ncr mod p code (#1325) 2020-11-22 23:05:01 +05:30
sum_of_digits.cpp formatting source-code for 9bc80876e8 2020-06-22 12:05:13 +00:00
vector_cross_product.cpp cross product of two vectors (#1292) 2021-02-05 15:13:45 +05:30
volume.cpp feat: added math/volume.cpp (#1796) 2021-10-26 13:19:58 +05:30

Prime factorization

Prime Factorization is a very important and useful technique to factorize any number into its prime factors. It has various applications in the field of number theory.

The method of prime factorization involves two function calls. First: Calculating all the prime number up till a certain range using the standard Sieve of Eratosthenes.

Second: Using the prime numbers to reduce the the given number and thus find all its prime factors.

The complexity of the solution involves approx. O(n logn) in calculating sieve of eratosthenes O(log n) in calculating the prime factors of the number. So in total approx. O(n logn).

Requirements: For compile you need the compiler flag for C++ 11