mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-02-07 12:37:22 +08:00
* 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 forbc87fea5* clang-format and clang-tidy fixes for0a19d1ad--------- 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>
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