Questions tagged [prime-factoring]

The decomposition of composite numbers into a unique list of prime numbers that, when multiplied together, equal that number.

Each positive integer has a unique prime factorization, that is a unique list of prime numbers that, when multiplied together, equal that number.

For example, the prime factorization of the composite number 1518 is 2 x 3 x 11 x 23. The prime factorization of any prime is that prime itself, and the prime factorization of 1 is the empty product.

While multiplying many large primes is easy, the reverse operation -- i.e. prime factorization -- is computationally expensive. This fact is used in public key cryptography, such as RSA, which would be rendered insecure if an efficient prime factorization algorithm were to be found.

479 questions
188
votes
28 answers

Algorithm to find Largest prime factor of a number

What is the best approach to calculating the largest prime factor of a number? I'm thinking the most efficient would be the following: Find lowest prime number that divides cleanly Check if result of division is prime If not, find next lowest Go to…
mercutio
  • 20,943
  • 10
  • 33
  • 37
85
votes
7 answers

Fast prime factorization module

I am looking for an implementation or clear algorithm for getting the prime factorization of N in either python, pseudocode or anything else well-readable. There are a few demands/facts: N is between 1 and ~20 digits No pre-calculated lookup table,…
orlp
  • 98,226
  • 29
  • 187
  • 285
47
votes
3 answers

How many prime numbers are there (available for RSA encryption)?

Am I mistaken in thinking that the security of RSA encryption, in general, is limited by the amount of known prime numbers? To crack (or create) a private key, one has to combine the right pair of prime numbers. Is it impossible to publish a list of…
pinhead
  • 907
  • 2
  • 10
  • 14
41
votes
6 answers

Segmented Sieve of Eratosthenes?

It's easy enough to make a simple sieve: for (int i=2; i<=N; i++){ if (sieve[i]==0){ cout << i << " is prime" << endl; for (int j = i; j<=N; j+=i){ sieve[j]=1; } } cout << i << " has " << sieve[i] << "…
John Smith
  • 9,380
  • 16
  • 43
  • 49
37
votes
3 answers

Rainbow tables as a solution to large prime factoring

In explanations I've read about public key cryptography, it is said that some large number is come up with by multiplying together 2 extremely large primes. Since factoring the product of large primes is almost impossibly time-consuming, you have…
Dinah
  • 48,876
  • 29
  • 126
  • 149
32
votes
2 answers

What's a nice method to factor gaussian integers?

I already have prime factorization (for integers), but now I want to implement it for gaussian integers but how should I do it? thanks!
26
votes
17 answers

Prime factorization - list

I am trying to implement a function primeFac() that takes as input a positive integer n and returns a list containing all the numbers in the prime factorization of n. I have gotten this far but I think it would be better to use recursion here, not…
Snarre
  • 527
  • 3
  • 12
  • 21
24
votes
4 answers

How does being able to factor large numbers determine the security of popular encryption algorithms?

How is the encryption algorithm's security dependent on factoring large numbers? For example, I've read on some math-programming forums that by using the Quadratic Sieve or the General Number Field Sieve, one can factor a 256 bit number with…
Mithrax
  • 7,053
  • 17
  • 52
  • 58
21
votes
3 answers

Confused on Miller-Rabin

As an exercise for myself, I'm implementing the Miller-Rabin test. (Working through SICP). I understand Fermat's little theorem and was able to successfully implement that. The part that I'm getting tripped up on in the Miller-Rabin test is this "1…
hraesvelgr
  • 3,961
  • 2
  • 32
  • 58
17
votes
8 answers

Prime factors in Haskell

I'm new to Haskell. How to generate a list of lists which contains prime factors of next integers? Currently, I only know how to generate prime numbers: primes = map head $ iterate (\(x:xs) -> [y | y<-xs, y `mod` x /= 0 ]) [2..]
Chris
  • 562
  • 1
  • 5
  • 20
16
votes
7 answers

Brute-force, single-threaded prime factorization

Up for consideration is the following function which can be used to (relatively quickly) factor a 64-bit unsigned integer into its prime factors. Note that the factoring is not probabalistic (i.e., it is exact). The algorithm is already fast enough…
Michael Goldshteyn
  • 65,547
  • 23
  • 122
  • 176
15
votes
6 answers

Prime Factors In C#

I want to create a program in C# 2005 which calculates prime factors of a given input. i want to use the basic and simplest things, no need to create a method for it nor array things etc. just simple modulus. is there any code which fulfills what i…
Aliza
  • 151
  • 1
  • 1
  • 4
13
votes
1 answer

python prime factorization performance

I'm relatively new to python and I'm confused about the performance of two relatively simple blocks of code. The first function generates a prime factorization of a number n given a list of primes. The second generates a list of all factors of n. …
user2869495
  • 133
  • 6
12
votes
4 answers

Find the sum of least common multiples of all subsets of a given set

Given: set A = {a0, a1, ..., aN-1} (1 ≤ N ≤ 100), with 2 ≤ ai ≤ 500. Asked: Find the sum of all least common multiples (LCM) of all subsets of A of size at least 2. The LCM of a setB = {b0, b1, ..., bk-1} is defined as the minimum…
11
votes
8 answers

Find the smallest regular number that is not less than N

Regular numbers are numbers that evenly divide powers of 60. As an example, 602 = 3600 = 48 × 75, so both 48 and 75 are divisors of a power of 60. Thus, they are also regular numbers. This is an extension of rounding up to the next power of two. I…
finnw
  • 45,253
  • 22
  • 134
  • 212
1
2 3
31 32