bdonelson
- 13
- 2
- TL;DR Summary
- Prime Number Sieve
I am new to this forum, and I want to see what everyone thought of my idea. I realize that "everyone" has a new idea, but I have not been able to find any references to something similar.
This is an algorithm of a prime sieve, and I am looking for ways to test its accuracy & efficiency. I am open to any suggestions.
Any comments would be appreciated.
Thank you.
This is an algorithm of a prime sieve, and I am looking for ways to test its accuracy & efficiency. I am open to any suggestions.
Code:
--------------------------------------------------------------------------------------------------------------------------------------------------------------
// Starting with the Subset { 6X ± 1 } arranged in pairs (5, 7) (11, 13) (17, 19) ... ( 6n - 1, 6n + 1)
// Minus_Check, and Plus_Check are indicators of ( Possible Prime ) status, Default Value = Prime
// ----------------------------------------------------------------------------------
N = 1000 // Set to Test Range
Max_Multiple = int ( N / 6 )
Stop_Value = sqrt ( Max_Multiple ) + 1
Starting_Side_Flag = 0 // Side_Flag is an indicator of which side of the 6X±1
Current_Odd_Number = 3
Current_Multiple = 1
First_Step = Current_Odd_Number
Next_Pair = Current_Multiple + First_Step // First Multiple to Set Check Value
Loop
If ( Starting_Side_Flag = 0 ) // Which Side of the Multiple
Then Starting_Side_Flag = 1
Else Starting_Side_Flag = 0
First_Step = Current_Odd_Number // First Multiple to Set Check Value
Second_Step = Current_Multiple * 2 // Second Multiple to Set Check Value
Current_Pair = Current_Multiple + First_Step // Goto First Record for Current Possible Prime
If ( Check = True ) // Check if Current Value is Marked as Prime
// Inside Loop
Loop
// First Step
Goto Record ( Next_Step )
If ( Side = 0 )
Set Minus_Check = 0
Else
Set Plus_Check = 0
End If
// Second Step
Current_Pair = Current_Pair + Second_Step
Goto Record ( Current_Pair )
If ( Side = 0 )
Set Minus_Check = 0
Else
Set Plus_Check = 0
End If
If ( Side_Flag = 1; 0; 1)
Exit Loop If ( Current_Pair = Max_Multiple )
Current_Pair = Current_Pair + First_Step
End Loop
// Inside Loop
If ( Starting_Side_Flag = 1 )
Current_Multiple = Current_Multiple + 1
Goto Current_Multiple
Exit Loop If ( Current_Multiple ≥ Stop_Value )
Current_Odd_Number = Current_Odd_Number + 2
If ( Starting_Side_Flag = 1)
Starting_Side_Flag = 0
End If // Check if Current Value is Marked as Prime
End Loop
// Outside Loop
End
--------------------------------------------------------------------------------------------------------------------------------------------------------------
Any comments would be appreciated.
Thank you.
Last edited by a moderator: