get prime numbers in a random sequence using bit shift operators

how to generate prime numbers in a random sequence  using bitwise operators
prasad2315Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Infinity08Connect With a Mentor Commented:
You can of course make use of bitwise operators in any of the standard algorithms for finding primes (like the sieve of Eratosthenes), but that's a bit pointless.

I know of no algorithm that is based on bitwise operators to calculate primes. For the simple reason that bitwise operators are tied to powers of 2. And that doesn't offer an advantage to finding primes, as a prime can't be divisible by any value (other than 1 and itself), not just powers of 2.
0
 
Infinity08Commented:
What do you mean by "in random sequence" ? Why using bitwise operators ?

What is this for ?

Do you want prime numbers within a certain range ? Or just any prime numbers ?
0
 
prasad2315Author Commented:
i mean prime numbers in a range

how to generate prime numbers with in a certain range using bit operators ?
this was the question asked to me in an interview
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
evilrixSenior Software Engineer (Avast)Commented:
I'm not sure there is enough info in the Q to provide and effective or useful answer.
0
 
Infinity08Commented:
I've got the same impression that there's something missing ... What's the relation between prime numbers and bitwise operations ?
0
 
evilrixSenior Software Engineer (Avast)Commented:
I8. Actually I don't know why I'm monitoring this TA as numbers are definitely your thing and not mine -- I am a self confessed Numerophobe :->
0
 
ozoCommented:
You might use bit operators in a Feedback Shift Register pseudo-random number generator to select the random prime once it has been generated.
0
 
ozoCommented:
you might use a binary GCD algorithm for trial divisions.
You might shift by the word size to get a bit mask and an array index for doing a sieve that uses more bits than your word size.
Or maybe you want to find primes in GF(2)
0
All Courses

From novice to tech pro — start learning today.