TheAlgorithms-C-Plus-Plus/math
Omkar Langhe 026557115c
Adding algorithm to check if number is prime or not. (#834)
* 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
2020-06-13 21:15:37 +05:30
..
binary_exponent.cpp Resolve typo errors 2020-04-04 18:16:40 +05:30
check_prime.cpp Adding algorithm to check if number is prime or not. (#834) 2020-06-13 21:15:37 +05:30
double_factorial.cpp Update double_factorial.cpp 2020-04-26 08:41:22 +02:00
eulers_totient_function.cpp Format Euler's Totient 2020-03-31 23:26:32 +02:00
extended_euclid_algorithm.cpp Create extended_euclid_algorithm.cpp (#759) 2020-05-18 14:32:42 +02:00
factorial.cpp factorial.cpp (#561) 2019-12-05 23:02:52 +01:00
fast_power.cpp Add fast power (#691) 2019-12-26 09:30:30 +01:00
fibonacci.cpp Fibonacci funtion added (#767) 2020-05-19 17:50:15 +02:00
greatest_common_divisor_euclidean.cpp feat: add euclidean algorithm implementation of gcd 2019-12-28 01:10:53 -05:00
greatest_common_divisor.cpp Added factorisation technique (#604) 2019-12-04 09:24:48 +01:00
least_common_multiple.cpp feat: Added a function for finding the least common multiple (#840) 2020-06-13 04:17:32 +05:30
modular_inverse_fermat_little_theorem.cpp Fix spacing 2020-05-11 00:55:16 +02:00
number_of_positive_divisors.cpp Modified description 2020-04-15 09:23:00 +05:30
power_for_huge_numbers.cpp Flatten the math directory (#657) 2019-11-28 14:34:13 +01:00
prime_factorization.cpp Flatten the math directory (#657) 2019-11-28 14:34:13 +01:00
prime_numbers.cpp Create PrimeNumbers.cpp (#607) 2019-12-04 09:05:08 +01:00
primes_up_to_10^8.cpp Prime (#585) 2019-12-07 08:33:23 +01:00
README.md Flatten the math directory (#657) 2019-11-28 14:34:13 +01:00
sieve_of_eratosthenes.cpp Flatten the math directory (#657) 2019-11-28 14:34:13 +01:00
sqrt_double.cpp fix: sqrt_double hangs on x < 1 (#760) 2020-05-20 03:05:03 +00:00

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