New Idea for Prime Number Sieve

  • Thread starter Thread starter bdonelson
  • Start date Start date
  • Tags Tags
    Prime numbers
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
36 replies · 3K views
Ok, that does sound like a good idea. Thank you.

Maybe this is closer to what you asking for?

Here is the center of the algorithm.

Code:
// FirstStep is set to a value based on the Current Multiple of 6 Managed in the Outer Loop ( 6, 12, 18, etc. )
// SecondStep is set to a value based on the Current Odd Number ( 3, 5, 7, 9, 11, 13, 15, etc )

While (Inside = True)                                                       // Inside Loop

        {
            List.AdvanceRecords(FirstStep);                           // Advance to the next Value based on FirstStep

            If(Side = 0)
                List.MCheck();                                                   // Set the Non-Prime Flag for the Minus
            Else
                List.PCheck();                                                    // Set the Non-Prime Flag for the Plus

            List.AdvanceRecords(SecondStep)                     // Advance to the next Value based on SecondStep

            If ( SideFlag = 1)                                                // SideFlag Switches
                SideFlag = 0;
            Else
                SideFlag = 1;

            If(Side = 0)
                List.MCheck();                                                  // Set the Non-Prime Flag for the Minus
            Else
                List.PCheck();                                                   // Set the Non-Prime Flag for the Plus


            If ( SideFlag = 1)                                                 // SideFlag Switches
                SideFlag = 0;
            Else
                SideFlag = 1;

            If ( CurrentStep <= MaxMultiple )                     // MaxMultiple = Maximum Prime Value / 6

                CurrentStep = CurrentStep + FirstStep + SecondStep;    // Tracking Which Prime is Used

            Else

                Inside = False;

        }                                                                   // Inside Loop

Is this easier to follow?
 
Physics news on Phys.org
bdonelson said:
Is this easier to follow?
Did you run it, and get a correct result?
 
  • Like
Likes   Reactions: berkeman
Apparently, no one understands to think. Why did I waste my time. Goodbye
 
Baluncore said:
Did you run it, and get a correct result?
I think the OP indirectly just answered that.
 
  • Like
Likes   Reactions: berkeman
bdonelson said:
Why did I waste my time.
You failed to clearly communicate your algorithm. You only needed to code your algorithm, run it, and prove it once. It would then have been possible for us to compare that to other algorithms. You actually wasted our time.
 
  • Like
Likes   Reactions: berkeman and PeterDonis
bdonelson said:
I would to comment here that apparently most people here do not appear to understand the concept of psuedo code. I have seen examples of people that didn't recognize it to begin with.
I beg to differ. I'd be willing to bet that all of the people responding here are very familiar with the concept of pseudocode. Speaking for myself, I taught a variety of programming languages, at least six or seven of them, over a course of about 20 years. Pseudocode was an important part of all of these classes.

bdonelson said:
In computer science, pseudocode is a description of the steps in an algorithm using a mix of conventions of programming languages (like assignment operator, conditional operator, loop) with informal, usually self-explanatory, notation of actions and conditions.
We're all very familiar with these concepts. What was confusing to myself and others was your unusual use of goto statements.

Thread is still closed.