Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Challenge for you...
#5
no chance to produce 100 primes with that lame formula unless you use bignum
here are the first 6 primes Rolleyes 
Code: (Select All)
Dim As Long i

For i = 1 To 6
    Print i, nprime(i)
Next

Function factorial# (n As Long)
    Dim As Long i
    Dim As Double f
    If n = 0 Or n = 1 Then
        factorial = 1
        Exit Function
    End If
    f = 1
    For i = 2 To n
        f = f * i
    Next
    factorial = f
End Function

Function nprime~&& (n As Long)
    Dim As Double s1, s2, s3, Pi: Pi = 3.1415926535897932384626433832795#
    Dim As Long i, j
    s1 = 0#
    For i = 1 To 2 ^ n
        s2 = 0#
        For j = 1 To i
            s3 = Cos(Pi * (factorial(j - 1) + 1) / j)
            s2 = s2 + Fix(s3 * s3)
        Next
        s1 = s1 + Fix(((n / s2) ^ (1 / n)))
    Next
    nprime = 1 + s1
End Function
Reply


Messages In This Thread
Challenge for you... - by eoredson - 04-20-2023, 04:08 AM
RE: Challenge for you... - by bplus - 04-20-2023, 02:02 PM
RE: Challenge for you... - by mnrvovrfc - 04-20-2023, 02:52 PM
RE: Challenge for you... - by bplus - 04-20-2023, 03:26 PM
RE: Challenge for you... - by Jack - 04-20-2023, 05:07 PM
RE: Challenge for you... - by mnrvovrfc - 04-20-2023, 05:13 PM
RE: Challenge for you... - by Petr - 04-20-2023, 06:32 PM
RE: Challenge for you... - by bplus - 04-20-2023, 06:34 PM
RE: Challenge for you... - by Kernelpanic - 04-20-2023, 08:39 PM
RE: Challenge for you... - by Kernelpanic - 04-20-2023, 07:33 PM
RE: Challenge for you... - by mnrvovrfc - 04-20-2023, 07:44 PM
RE: Challenge for you... - by Petr - 04-20-2023, 07:44 PM
RE: Challenge for you... - by Jack - 04-20-2023, 08:09 PM
RE: Challenge for you... - by Petr - 04-20-2023, 08:18 PM
RE: Challenge for you... - by Kernelpanic - 04-20-2023, 08:34 PM
RE: Challenge for you... - by bplus - 04-20-2023, 08:37 PM
RE: Challenge for you... - by bplus - 04-20-2023, 08:35 PM
RE: Challenge for you... - by Kernelpanic - 04-20-2023, 08:45 PM
RE: Challenge for you... - by bplus - 04-20-2023, 08:55 PM
RE: Challenge for you... - by Jack - 04-20-2023, 09:00 PM
RE: Challenge for you... - by Kernelpanic - 04-20-2023, 09:13 PM
RE: Challenge for you... - by bplus - 04-20-2023, 09:23 PM
RE: Challenge for you... - by Kernelpanic - 04-22-2023, 04:23 PM
RE: Challenge for you... - by Jack - 04-20-2023, 09:54 PM
RE: Challenge for you... - by eoredson - 04-21-2023, 12:27 AM
RE: Challenge for you... - by Jack - 04-21-2023, 12:50 AM
RE: Challenge for you... - by eoredson - 04-21-2023, 01:04 AM
RE: Challenge for you... - by mnrvovrfc - 04-21-2023, 01:28 AM
RE: Challenge for you... - by Jack - 04-21-2023, 01:14 AM
RE: Challenge for you... - by Jack - 04-21-2023, 01:34 AM
RE: Challenge for you... - by mnrvovrfc - 04-21-2023, 02:27 AM
RE: Challenge for you... - by eoredson - 04-21-2023, 02:09 AM
RE: Challenge for you... - by mnrvovrfc - 04-21-2023, 02:33 AM
RE: Challenge for you... - by Jack - 04-21-2023, 02:30 AM
RE: Challenge for you... - by Jack - 04-21-2023, 02:33 AM
RE: Challenge for you... - by eoredson - 04-21-2023, 02:33 AM
RE: Challenge for you... - by bplus - 04-21-2023, 01:20 PM
RE: Challenge for you... - by Jack - 04-21-2023, 02:44 AM
RE: Challenge for you... - by DANILIN - 04-21-2023, 01:49 PM
RE: Challenge for you... - by mnrvovrfc - 04-21-2023, 02:18 PM
RE: Challenge for you... - by bplus - 04-21-2023, 03:42 PM
RE: Challenge for you... - by mnrvovrfc - 04-21-2023, 04:07 PM
RE: Challenge for you... - by mnrvovrfc - 04-22-2023, 04:53 PM
RE: Challenge for you... - by Kernelpanic - 04-22-2023, 09:20 PM
RE: Challenge for you... - by mnrvovrfc - 04-22-2023, 09:25 PM
RE: Challenge for you... - by Kernelpanic - 04-22-2023, 09:30 PM
RE: Challenge for you... - by bplus - 04-22-2023, 11:06 PM
RE: Challenge for you... - by Jack - 04-23-2023, 03:37 PM
RE: Challenge for you... - by david_uwi - 04-23-2023, 04:02 PM
RE: Challenge for you... - by mnrvovrfc - 04-23-2023, 04:44 PM
RE: Challenge for you... - by Kernelpanic - 04-23-2023, 04:36 PM
RE: Challenge for you... - by Kernelpanic - 04-23-2023, 04:46 PM
RE: Challenge for you... - by bplus - 04-23-2023, 05:30 PM
RE: Challenge for you... - by Jack - 04-23-2023, 05:36 PM
RE: Challenge for you... - by bplus - 04-23-2023, 05:47 PM
RE: Challenge for you... - by david_uwi - 04-23-2023, 05:44 PM
RE: Challenge for you... - by Jack - 04-23-2023, 06:12 PM
RE: Challenge for you... - by DANILIN - 04-28-2023, 06:57 PM
RE: Challenge for you... - by Jack - 04-28-2023, 07:06 PM



Users browsing this thread: 27 Guest(s)