Calculating Anti-Primes
#12
Code: (Select All)
DefLng A-S
Dim p(20), k(250) As Integer
p(1) = 2: p(2) = 3: p(3) = 5: p(4) = 7: p(5) = 11: p(6) = 13: p(7) = 17: p(8) = 19: p(9) = 23: p(10) = 29
'yes these are primes
tt = Timer
Print "anti-prime, number of factors"
For i = 6 To 7000000 Step 2
    iq = i
    For j = 1 To 10
        k(j) = 0
        If p(j) > iq Then Exit For
        If iq = 1 Then Exit For
        Do Until (iq Mod p(j) <> 0)
            k(j) = k(j) + 1: iq = iq \ p(j)
        Loop
    Next j
    isum = 1
    For jk = 1 To j
        isum = (k(jk) + 1) * isum
    Next jk
    If isum > kmax Then
        Print i, isum
        kmax = isum
        knum = knum + 1
    End If
    k = 0
Next i
Print Timer - tt
Print knum + 3 'missed 1,2,4
Anti-primes have lots of small prime factors. So with that knowledge you can speed it up (a little)
Reply


Messages In This Thread
Calculating Anti-Primes - by Space_Ghost - 07-06-2023, 06:56 PM
RE: Calculating Anti-Primes - by bplus - 07-06-2023, 07:16 PM
RE: Calculating Anti-Primes - by Space_Ghost - 07-06-2023, 08:00 PM
RE: Calculating Anti-Primes - by mnrvovrfc - 07-06-2023, 07:54 PM
RE: Calculating Anti-Primes - by Space_Ghost - 07-06-2023, 08:11 PM
RE: Calculating Anti-Primes - by bplus - 07-06-2023, 11:38 PM
RE: Calculating Anti-Primes - by Space_Ghost - 07-06-2023, 11:43 PM
RE: Calculating Anti-Primes - by Jack - 07-07-2023, 11:50 AM
RE: Calculating Anti-Primes - by Space_Ghost - 07-07-2023, 04:38 PM
RE: Calculating Anti-Primes - by Stuart - 07-07-2023, 08:15 PM
RE: Calculating Anti-Primes - by Space_Ghost - 07-07-2023, 10:12 PM
RE: Calculating Anti-Primes - by david_uwi - 07-08-2023, 04:10 PM
RE: Calculating Anti-Primes - by Jack - 07-08-2023, 04:39 PM
RE: Calculating Anti-Primes - by Kernelpanic - 08-13-2023, 12:23 AM
RE: Calculating Anti-Primes - by david_uwi - 07-08-2023, 05:45 PM
RE: Calculating Anti-Primes - by Jack - 07-08-2023, 05:59 PM
RE: Calculating Anti-Primes - by Space_Ghost - 07-08-2023, 07:02 PM
RE: Calculating Anti-Primes - by Jack - 07-08-2023, 07:14 PM



Users browsing this thread: 1 Guest(s)