mirror of
https://hub.njuu.cf/TheAlgorithms/C-Plus-Plus.git
synced 2023-10-11 13:05:55 +08:00
5ef7ad5cfe
* check_prime_update docs: added links to file @brief and @details. moved previous @brief to be with function, made comments easier to read in general and added boilerplate documentation to functions. chore: removed bool result and most brackets in is_prime. Moved assert tests to their own function and added more in, test success now returns message. * Delete cmake-build-debug directory * clang-format * original box_stacking documentation start point * Update math/check_prime.cpp Co-authored-by: realstealthninja <68815218+realstealthninja@users.noreply.github.com> * Update math/check_prime.cpp Co-authored-by: realstealthninja <68815218+realstealthninja@users.noreply.github.com> * Delete box_stacking.cpp * Update check_prime.cpp improved files @details text, removed generic t template - replaced with long long * Update math/check_prime.cpp Co-authored-by: realstealthninja <68815218+realstealthninja@users.noreply.github.com> * Update math/check_prime.cpp Co-authored-by: realstealthninja <68815218+realstealthninja@users.noreply.github.com> * Update math/check_prime.cpp Co-authored-by: realstealthninja <68815218+realstealthninja@users.noreply.github.com> * Update check_prime.cpp removed cin/cout interaction * Update check_prime.cpp * Update math/check_prime.cpp Co-authored-by: realstealthninja <68815218+realstealthninja@users.noreply.github.com> * Update math/check_prime.cpp Co-authored-by: realstealthninja <68815218+realstealthninja@users.noreply.github.com> * Update math/check_prime.cpp Co-authored-by: realstealthninja <68815218+realstealthninja@users.noreply.github.com> * Update math/check_prime.cpp Co-authored-by: realstealthninja <68815218+realstealthninja@users.noreply.github.com> * Update math/check_prime.cpp Co-authored-by: realstealthninja <68815218+realstealthninja@users.noreply.github.com> * Update math/check_prime.cpp Co-authored-by: realstealthninja <68815218+realstealthninja@users.noreply.github.com> * Update math/check_prime.cpp Co-authored-by: realstealthninja <68815218+realstealthninja@users.noreply.github.com> * Update math/check_prime.cpp Co-authored-by: David Leal <halfpacho@gmail.com> * Update check_prime.cpp * Update math/check_prime.cpp Co-authored-by: David Leal <halfpacho@gmail.com> --------- Co-authored-by: realstealthninja <68815218+realstealthninja@users.noreply.github.com> Co-authored-by: David Leal <halfpacho@gmail.com> |
||
---|---|---|
.. | ||
aliquot_sum.cpp | ||
approximate_pi.cpp | ||
area.cpp | ||
armstrong_number.cpp | ||
binary_exponent.cpp | ||
binomial_calculate.cpp | ||
check_amicable_pair.cpp | ||
check_factorial.cpp | ||
check_prime.cpp | ||
CMakeLists.txt | ||
complex_numbers.cpp | ||
double_factorial.cpp | ||
eratosthenes.cpp | ||
eulers_totient_function.cpp | ||
extended_euclid_algorithm.cpp | ||
factorial.cpp | ||
fast_power.cpp | ||
fibonacci_fast.cpp | ||
fibonacci_large.cpp | ||
fibonacci_matrix_exponentiation.cpp | ||
fibonacci_sum.cpp | ||
fibonacci.cpp | ||
finding_number_of_digits_in_a_number.cpp | ||
gcd_iterative_euclidean.cpp | ||
gcd_of_n_numbers.cpp | ||
gcd_recursive_euclidean.cpp | ||
integral_approximation2.cpp | ||
integral_approximation.cpp | ||
inv_sqrt.cpp | ||
large_factorial.cpp | ||
large_number.h | ||
largest_power.cpp | ||
lcm_sum.cpp | ||
least_common_multiple.cpp | ||
linear_recurrence_matrix.cpp | ||
magic_number.cpp | ||
miller_rabin.cpp | ||
modular_division.cpp | ||
modular_exponentiation.cpp | ||
modular_inverse_fermat_little_theorem.cpp | ||
modular_inverse_simple.cpp | ||
n_bonacci.cpp | ||
n_choose_r.cpp | ||
ncr_modulo_p.cpp | ||
number_of_positive_divisors.cpp | ||
perimeter.cpp | ||
power_for_huge_numbers.cpp | ||
power_of_two.cpp | ||
prime_factorization.cpp | ||
prime_numbers.cpp | ||
primes_up_to_billion.cpp | ||
quadratic_equations_complex_numbers.cpp | ||
README.md | ||
realtime_stats.cpp | ||
sieve_of_eratosthenes.cpp | ||
sqrt_double.cpp | ||
string_fibonacci.cpp | ||
sum_of_binomial_coefficient.cpp | ||
sum_of_digits.cpp | ||
vector_cross_product.cpp | ||
volume.cpp |
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