Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Prime pattern 6 +/- 1
#5
(06-30-2022, 12:46 PM)david_uwi Wrote: Here's one that I wrote for QB4.5 (amazingly you can go up to 100 million despite the memory restrictions).

Code: (Select All)
Rem finding primes to 100 million!!!
TT = Timer
DefLng I-N
N = 3226000
Dim A(0 To N) As Long
Dim B(0 To 30) As Long
B(0) = 1
For I = 1 To 30
    B(I) = B(I - 1) + B(I - 1)
Next I
For J = 2 To 5000
    J1 = J \ 31: J2 = J Mod 31
    If (A(J1) And B(J2)) = 0 Then
        K1 = J + J - 1
        K2 = K1 * J - K1 + J
        For I = K2 To 50000000 Step K1
            I1 = I \ 31: I2 = I Mod 31
            A(I1) = (A(I1) Or B(I2))
        Next I
    End If
Next J
Rem *** End of main routine - Printout starts here ***
'PRINT " 2 ";
For I = 2 To 50000000
    I1 = I \ 31: I2 = I Mod 31
    L = A(I1) And B(I2)
    If L = 0 Then
        'PRINT I + I - 1; 'unrem to print
        L1 = L1 + 1
    End If
Next I
Print "Number of primes to 100M = "; L1 + 1; Timer - TT

That's pretty fast @david_uwi, looks like a variation on a 30 wheeler, 1.5 secs on my system, mine takes 2.5 plus but mine can factor numbers once the sieving is complete. Shall we have a look at my 2310 wheeler? ought to do much better now that I am using 0.8.2 with optimized compiler. ;-))
b = b + ...
Reply


Messages In This Thread
Prime pattern 6 +/- 1 - by SMcNeill - 06-30-2022, 10:49 AM
RE: Prime pattern 6 +/- 1 - by bplus - 06-30-2022, 12:25 PM
RE: Prime pattern 6 +/- 1 - by bplus - 06-30-2022, 12:29 PM
RE: Prime pattern 6 +/- 1 - by david_uwi - 06-30-2022, 12:46 PM
RE: Prime pattern 6 +/- 1 - by bplus - 06-30-2022, 01:32 PM
RE: Prime pattern 6 +/- 1 - by david_uwi - 06-30-2022, 02:39 PM
RE: Prime pattern 6 +/- 1 - by triggered - 07-01-2022, 11:29 AM
RE: Prime pattern 6 +/- 1 - by SMcNeill - 07-01-2022, 11:40 AM
RE: Prime pattern 6 +/- 1 - by bplus - 07-01-2022, 12:51 PM
RE: Prime pattern 6 +/- 1 - by bplus - 07-01-2022, 01:06 PM
RE: Prime pattern 6 +/- 1 - by bplus - 07-01-2022, 01:15 PM
RE: Prime pattern 6 +/- 1 - by david_uwi - 07-01-2022, 03:55 PM
RE: Prime pattern 6 +/- 1 - by triggered - 07-07-2022, 10:46 AM



Users browsing this thread: 5 Guest(s)