mirror of
https://hub.njuu.cf/TheAlgorithms/C-Plus-Plus.git
synced 2023-10-11 13:05:55 +08:00
026557115c
* Optimized algorithm to check if number is prime or not. * logic to check if given number is prime or not. * logic to check if given number is prime or not. * logic to check if given number is prime or not. * logic to check if given number is prime or not. * Included appropriate comments as per standards. * variable name renamed to num * added @file and @brief in comment. Also added template and variable name changed from is_prime to result * added @file and @brief in comment. Also added template and variable name changed from is_prime to result * added template parameter T type in loop |
||
---|---|---|
.. | ||
binary_exponent.cpp | ||
check_prime.cpp | ||
double_factorial.cpp | ||
eulers_totient_function.cpp | ||
extended_euclid_algorithm.cpp | ||
factorial.cpp | ||
fast_power.cpp | ||
fibonacci.cpp | ||
greatest_common_divisor_euclidean.cpp | ||
greatest_common_divisor.cpp | ||
least_common_multiple.cpp | ||
modular_inverse_fermat_little_theorem.cpp | ||
number_of_positive_divisors.cpp | ||
power_for_huge_numbers.cpp | ||
prime_factorization.cpp | ||
prime_numbers.cpp | ||
primes_up_to_10^8.cpp | ||
README.md | ||
sieve_of_eratosthenes.cpp | ||
sqrt_double.cpp |
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