TheAlgorithms-C-Plus-Plus/math
Ayaan Khan 2aec4efdd3
fix: integer overflow due to multiplication fixed (#886)
* formatting source-code for 72c365dcd3

* Fixed Bug [munmap_chunck() core dumped]

* formatting source-code for b06bbf4dc6

* fixed line spacing

* fixed line spacing

* fixed documentation

* closed the paranthesis of line 3

* formatting source-code for 8233eda889

* Bug Fix heap sort [Fresh Implementation]

* formatting source-code for e464ddac36

* Bug Fix heap sort [Fresh Implementation]

* formatting source-code for 803981c831

* switched to normal functions from lambda

* formatting source-code for ced5dcd6c4

* Added template and test cases

* formatting source-code for 7c8617fa46

* fixed docs

* fixed line spacing in tests

* fix docs

* Multiplication result may overflow 'int' before it is converted to 'long'.

* fixed cpplint long -> int64

* fixed compiler error

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-06-23 23:50:45 +05:30
..
binary_exponent.cpp Major rework to improve code quality and add automation checks (#805) 2020-06-19 21:34:56 +05:30
check_prime.cpp Major rework to improve code quality and add automation checks (#805) 2020-06-19 21:34:56 +05:30
CMakeLists.txt Major rework to improve code quality and add automation checks (#805) 2020-06-19 21:34:56 +05:30
double_factorial.cpp Major rework to improve code quality and add automation checks (#805) 2020-06-19 21:34:56 +05:30
eulers_totient_function.cpp Major rework to improve code quality and add automation checks (#805) 2020-06-19 21:34:56 +05:30
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 Major rework to improve code quality and add automation checks (#805) 2020-06-19 21:34:56 +05:30
fibonacci_large.cpp Major rework to improve code quality and add automation checks (#805) 2020-06-19 21:34:56 +05:30
fibonacci.cpp Major rework to improve code quality and add automation checks (#805) 2020-06-19 21:34:56 +05:30
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
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
least_common_multiple.cpp feat: Added a function for finding the least common multiple (#840) 2020-06-13 04:17:32 +05:30
miller_rabin.cpp formatting source-code for a48d05fb62 2020-06-21 17:42:09 +00:00
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
number_of_positive_divisors.cpp Major rework to improve code quality and add automation checks (#805) 2020-06-19 21:34:56 +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
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 Major rework to improve code quality and add automation checks (#805) 2020-06-19 21:34:56 +05:30
primes_up_to_billion.cpp fix: integer overflow due to multiplication fixed (#886) 2020-06-23 23:50:45 +05:30
README.md Major rework to improve code quality and add automation checks (#805) 2020-06-19 21:34:56 +05:30
realtime_stats.cpp Major rework to improve code quality and add automation checks (#805) 2020-06-19 21:34:56 +05:30
sieve_of_eratosthenes.cpp Major rework to improve code quality and add automation checks (#805) 2020-06-19 21:34:56 +05:30
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_digits.cpp formatting source-code for 9bc80876e8 2020-06-22 12:05:13 +00:00

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