prime-factoring

C or C++: Libraries for factoring integers?

It seems that there are several really fast prime factorization algorithms around (one that looks ideal is quadratic sieving). However, rather than make my own (likely poor) implementation I would like to use a ready-made library for simplicity. I need to be able to factor integers of up to 15 digits efficiently. Because of that, I'm no...

n-th prime number problem, need to speed it up a bit

There is simple cipher that translates number to series of . ( ) In order to encrypt a number (0 .. 2147483647) to this representation, I (think I) need: prime factorization for given p (p is Prime), order sequence of p (ie. PrimeOrd(2) == 0, PrimeOrd(227) == 49) Some examples 0 . 6 (()()) 1 () ...

Find all possible factors in KenKen puzzle 'multiply' domain

A KenKen puzzle is a Latin square divided into edge-connected domains: a single cell, two adjacent cells within the same row or column, three cells arranged in a row or in an ell, etc. Each domain has a label which gives a target number and a single arithmetic operation (+-*/) which is to be applied to the numbers in the cells of the do...

Finding prime factors to large numbers using specially-crafted CPUs

My understanding is that many public key cryptographic algorithms these days depend on large prime numbers to make up the keys, and it is the difficulty in factoring the product of two primes that makes the encryption hard to break. It is also my understanding that one of the reasons that factoring such large numbers is so difficult, is ...

Python recursive program to prime factorize a number

I wrote the following program to prime factorize a number: import math def prime_factorize(x,li=[]): until = int(math.sqrt(x))+1 for i in xrange(2,until): if not x%i: li.append(i) break else: #This else belongs to for li.append(x) print li #First print state...

While loop example

x = y // 2 # For some y > 1 while x > 1: if y % x == 0: # Remainder print(y, 'has factor', x) break # Skip else x -= 1 else: # Normal exit print(y, 'is prime') This is an example for understanding while loop in a book I'm reading, I don't quite understand why a floor division and then y % x? Can someone please...

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! ...

Exceeding the size of lists in python

I'm trying to implement the sieve of eratosthenes in python, however when trying to find all primes up to the sqare root of for instance 779695003923747564589111193840021 I get an error saying result of range() has too many items. My question is, how do I avoid this problem, if I instantiate the list with a while loop I will get an error...

Prime Numbers Code Help

Hello Everybody, I am suppose to "write a Java program that reads a positive integer n from standard input, then prints out the first n prime number." It's divided into 3 parts. 1st: This function will return true or false according to whether m is prime or composite. The array argument P will contain a sufficient number of primes to d...

Threading a prime number finder in C++

How can I use threading to write a program that finds the prime numbers between 0 and 1001? ...

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 security. This seems like a problem that could be trivially solved with rainbow tables. If ...

Finding the optimum column and row size for a table with n elements and a given range for its proportion

I am looking for an optimum way to create a table from n elements so that ideally there are no empty cells, but at the same time the proportion of the table dimensions colums / rows becomes as close to 1 as possible. Of course if n is a square number it is easy since then cols = rows = sqrt( n ); If n is a prime number it is also cle...

Making solution for Project Euler more efficient.

Hey everyone, Originally, I was having some issues getting this code to function, but after a little tweaking I got it debugged and ready to go. I have gone through several revisions of this program. I started with integer values only to find that the number was too large to fit into an int. I then changed to BigIntegers, which proved ...

Finding largest prime factor of a composite number in c

I am accepting a composite number as an input. I want to print all its factors and also the largest prime factor of that number. I have written the following code. It is working perfectly ok till the number 51. But if any number greater than 51 is inputted, wrong output is shown. how can I correct my code? #include<stdio.h> void main() ...

Write an algorithm to return the prime numbers of an integer, for example if your input is 10 the output is list a with elements 2 and 5

this one i get as assignment in discrete maths. i try to do like this. procedure prime_numbers (x) n:= 1 for i:= to n<=x do n mod i=1 then return (prime) end prime_number. ...

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 to find that a number is prime or has few very large factors in a matter of several second...

Finding the prime factor of a Long number using Java.

public class prime { public static void main(String[] args) { long thing = 600851475143L; for(long i = 300425737571L ; i == 0 ; i-- ){ if (thing % i == 0) { long answer = i; System.out.println(answer); break; } } } } This is the code I currently have, however I have been r...