New Idea for Prime Number Sieve

  • Thread starter Thread starter bdonelson
  • Start date Start date
  • Tags Tags
    Prime numbers
Click For Summary
The discussion centers around a new algorithm for a prime number sieve, which utilizes the subset {6X ± 1} to identify potential primes. The author is seeking feedback on the algorithm's accuracy and efficiency, noting that it has been tested up to 100,000 primes. Participants question the implementation details, particularly the use of Goto statements, and express skepticism about the algorithm's ability to confirm prime status. The author clarifies that the algorithm is written in C++ and emphasizes its unique approach, which they believe distinguishes it from existing methods. Overall, the thread highlights the need for clarity in algorithm structure and the importance of community input for refinement.
  • #31
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?
 
Technology news on Phys.org
  • #32
bdonelson said:
Is this easier to follow?
Did you run it, and get a correct result?
 
  • Like
Likes berkeman
  • #33
Apparently, no one understands to think. Why did I waste my time. Goodbye
 
  • #34
Baluncore said:
Did you run it, and get a correct result?
I think the OP indirectly just answered that.
 
  • Like
Likes berkeman
  • #35
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 berkeman and PeterDonis
  • #36
bdonelson said:
Apparently, no one understands to think. Why did I waste my time. Goodbye
Thread closed.
 
  • #37
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.
 

Similar threads

  • · Replies 28 ·
Replies
28
Views
4K
  • · Replies 97 ·
4
Replies
97
Views
9K
  • · Replies 16 ·
Replies
16
Views
2K
  • · Replies 4 ·
Replies
4
Views
10K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K