Top "Primes" questions

Primes or prime numbers are integers greater than 1 which are divisible only by themselves and 1, i.e.: 2, 3, 5, 7, 11, ... .

Fastest algorithm for primality test

I need to test primality on intervals between numbers which are really big (in the range of long long), so …

c++ algorithm math primes
How do I generate the first n prime numbers?

I am learning Ruby and doing some math stuff. One of the things I want to do is generate prime …

ruby primes
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 <&…

algorithm primes sieve-of-eratosthenes prime-factoring factors
Reason for 5381 number in DJB hash function?

Can anyone tell me why the number 5381 is used in DJB hash function ? DJB Hash function is h(0) = 5381 h(i) = 33 * …

algorithm hash primes
How to determine if a number is a prime with regex?

I found the following code example for Java on RosettaCode: public static boolean prime(int n) { return !new String(new …

java regex primes
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 …

c# primes prime-factoring
nᵗʰ ugly number

Numbers whose only prime factors are 2, 3, or 5 are called ugly numbers. Example: 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, ... 1 can be considered as 2^0. I am working on …

algorithm math primes factors hamming-numbers
Generate a list of primes up to a certain number

I'm trying to generate a list of primes below 1 billion. I'm trying this, but this kind of structure is pretty …

algorithm r primes
How do I find the nearest prime number?

Is there any nice algorithm to find the nearest prime number to a given real number? I only need to …

algorithm primes
How to implement an efficient infinite generator of prime numbers in Python?

This is not a homework, I am just curious. INFINITE is the key word here. I wish to use it …

python generator primes