Largest prime factor of 600851475143. More...
#include <stdint.h>#include <stdio.h>Go to the source code of this file.
Macros | |
| #define | MAX_PRIME_FACTOR_COUNT 64 |
| The size of the array to store prime factors. | |
Functions | |
| int | factor (int64_t n, int64_t prime_factors[]) |
| Factors an integer into primes. | |
| int | main (void) |
| #define MAX_PRIME_FACTOR_COUNT 64 |
The size of the array to store prime factors.
We have Omega(n) <= log2(n), where Omega(n) is the number of prime factors (including duplicates) of a positive integer n, because:
n = p_1 p_2 ... p_k >= 2*2*...*2 = 2^k,
where k = Omega(n). Since the maximum value of an int64_t is exactly 2^63 - 1, a size of 64 is sufficient.
| int factor | ( | int64_t | n, |
| int64_t | prime_factors[] | ||
| ) |
Factors an integer into primes.
| n | An integer > 1. |
| prime_factors | An array to store the prime factors of n. The results are in order from smallest to largest. |
n. Definition at line 42 of file 0003.c.
| int main | ( | void | ) |
Definition at line 23 of file 0003.c.