|
How can I display the prime numbers between 1 and 100 in c#?
Started by Sudhakar K on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Most efficient code....
For the first 10000 prime numbers? Most elegant way to generate prime numbers Prime number calculation funAssuming you wish to find prime numbers, this is a standard question.
|
|
How can I find prime numbers through bit operations in C++?
Started by Sirish Kumar on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
I found this c# code, I am sure you can the numbers....
One bit is sufficient for that.
Know." Explain how you know what a prime number is, explain some properties of prime numbers number is a prime or not.
|
|
Need a suggestion for an algorithm.
For a given number N i have to find all the prime numbers it's consisting of, like this:
N = 49 49 = 7 ^ 2 N = 168 168 = (2 ^ 3) * (3 ^ 1) * (7 ^ 1)
If you want to help me even more you can write the algo in c++.
Thanks...
Started by ggg on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
For ....
Basically just try dividing n by each prime number up to sqrt(n).
Repeat until you have a prime straightforward way is trial division.
If you can then that number is one of your factors.
By an integer smaller than it.
|
Ask your Facebook Friends
|
Which is the fastest algorithm to find out prime numbers using C++? I have used sieve's algorithm but I still want it to be faster!
Started by kasperasky on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
They are probably the fastest method to determine if large numbers are primes, especially because they can tell you if a number is not a ....
Is a prime number, there are various prime tests listed on wikipedia .
|
|
This problem struck me as a bit odd. I'm curious how you could represent a list of prime numbers in a database. I do not know of a single datatype that would be able to acuratly and consistently store a large amount of prime numbers. My concern is that...
Started by steven on
, 10 posts
by 10 people.
Answer Snippets (Read the full thread at stackoverflow):
2 Write....
Then you'd want some to 2.
Nothing that if you're storing sequences of prime numbers and your interest is in space-compression table, with the prime number in one column and it's sequence number in the other.
|
|
I'd like to print out all prime numbers from an array with method. I can do it with one int but don't know how to return certain numbers from array. Thanks for help!
public static boolean isPrime(int [] tab) { boolean prime = true; for (int i = 3; i &...
Started by landscape on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Simply iterate over the array, and for each number:
if (isPrime(n is prime One method to iterate through an array, call the first method with each number, and printI would suggest you separate this....
numbers is prime.
|
|
Hi All,
I am new to the programming world. I was just writing this code in python to generate N prime numbers. User should input the value for N which is the total number of prime numbers to print out. I have written this code but it doesn't throw the...
Started by Rahul Tripathi on
, 10 posts
by 10 people.
Answer Snippets (Read the full thread at stackoverflow):
While still_possibly_prime and ((testdivisor + 1) < possibleprime: lastprime = possibleprime....
Must be >= 1" else: lastprime = 2 # 2 is the very first prime number primesfound = 1 # Since 2 to divide a number by itself.
|
|
This is not a homework, I am just curious.
INFINITE is the key word here.
I wish to use it as for p in primes(). I believe that this is a built-in function in Haskell.
So, the answer cannot be as naive as "Just do a Sieve".
First of all, you do not know...
Started by Hamish Grubijan on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
While True: if q not in D: # not marked composite, must be prime yield q #first multiple of q = [] i = 2 while....
Using a bit set for primality.
As a bit set and sieve with all prime numbers below the square root of the upper bound.
|
|
Note: Version 2, below, uses the Sieve of Eratosthenes. There are several answers that helped with what I originally asked. I have chosen the Sieve of Eratosthenes method, implemented it, and changed the question title and tags appropriately. Thanks to...
Started by eleven81 on
, 9 posts
by 9 people.
Answer Snippets (Read the full thread at stackoverflow):
Throw out the temporary array, and instead write function that just prime-tests an integer and build a list of integers that are prime, before finally converting that to an array to return continue until temp[i]*temp[i] > ....
Your code.
|
|
For a library, I need to store the first primes numbers up to a limit L. This collection must have a O(1) lookup time (to check whether a number is prime or not) and it must be easy, given a number, to find the next prime number (assuming it is smaller...
Started by Samuel Tardieu on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
If you can figure out which ones are Mersenne or other easily represented prime numbers, you might, how about storing the numbers as the difference from the previous number? Then the size shouldn't rise by two explicitly and....
|