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

What would be the fastest method to test for primality in Java?

I am trying to find the fastest way to check whether a given number is prime or not (in Java). …

java performance algorithm primes
Most elegant way to generate prime numbers

What is the most elegant way to implement this function: ArrayList generatePrimes(int n) This function generates the first n …

c# java algorithm primes
Why use a prime number in hashCode?

I was just wondering why is that primes are used in a class's hashCode() method? For example, when using Eclipse …

java hashcode primes
Finding a prime number after a given number

How can I find the least prime number greater than a given number? For example, given 4, I need 5; given 7, I …

algorithm primes
How do I break a for-loop in PHP when conditions are met?

I'm diligently plugging away at some code that checks for divisibility (yes, it's to generate primes) and I want to …

php loops primes
Is there an upper limit on .txt file size?

As a Christmas gift I have written a small program in Java to calculate primes. My intention was to leave …

memory text-files primes filesize
Prime number function in R

I am trying to create a function to test if a given integer is a prime number, I tried using …

r primes
Finding prime factors

#include <iostream> using namespace std; void whosprime(long long x) { bool imPrime = true; for(int i = 1; i <= …

c++ primes prime-factoring factorization
Finding prime numbers with the Sieve of Eratosthenes (Originally: Is there a better way to prepare this array?)

Note: Version 2, below, uses the Sieve of Eratosthenes. There are several answers that helped with what I originally asked. I …

java arrays primes sieve-of-eratosthenes
Given Prime Number N, Compute the Next Prime?

A coworker just told me that the C# Dictionary collection resizes by prime numbers for arcane reasons relating to hashing. …

algorithm math primes