Creating a Prime Sieve with Boolean Expressions

  • Context: Java 
  • Thread starter Thread starter JasonRox
  • Start date Start date
  • Tags Tags
    Expressions Prime
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 3K views
Messages
2,394
Reaction score
4
I'm trying to create a sieve (prime sieve). A nice quick simple one using boolean expressions.

I remember on Visual Basics it began by creating like X number of boolean variables and then sieve them out by classifying them as false... and so on.

How to a create a large group of boolean variables?

I think it was something like p(i) and i=X, which X determined how many to create. It was something like this I think.

So, technically i is like a variable itselt because when I go through the loop, I should be able to go through steps like...

p(4) = false;
p(6) = false;
p(8) = false;

... all the way until I reach 2X.

So, how do you create this variable?

Thanks, I appreciate it.
 
Physics news on Phys.org