New Idea for Prime Number Sieve

  • Thread starter Thread starter bdonelson
  • Start date Start date
  • Tags Tags
    Prime numbers
Click For Summary
SUMMARY

The discussion centers on a new algorithm for generating prime numbers using a sieve method based on the subset {6X ± 1}. The algorithm, currently written in pseudocode and being implemented in C++, aims to efficiently identify potential primes by iterating through odd numbers and marking possible primes. Key components include the use of flags to track the current state and the implementation of a linked list structure to store results. The algorithm has been tested up to primes equal to 100,000, but participants express concerns regarding its clarity and functionality.

PREREQUISITES
  • Understanding of prime number generation algorithms
  • Familiarity with C++ programming language
  • Knowledge of linked list data structures
  • Basic concepts of algorithm efficiency and complexity analysis
NEXT STEPS
  • Research "Sieve of Eratosthenes" for comparison with the proposed algorithm
  • Learn about "C++ linked list implementation" for data storage techniques
  • Explore "Algorithm complexity analysis" to evaluate performance
  • Investigate "Pseudocode to C++ translation" for better implementation practices
USEFUL FOR

Mathematicians, computer scientists, and software developers interested in prime number algorithms, algorithm optimization, and data structure implementation in C++.

  • #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   Reactions: 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   Reactions: 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   Reactions: 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 4 ·
Replies
4
Views
10K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 10 ·
Replies
10
Views
8K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 13 ·
Replies
13
Views
7K
  • · Replies 7 ·
Replies
7
Views
3K