Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Challenge for you...
#58
My prime program
has been created that searches for prime numbers
according to formula of origin topic
but I feel an error in line

s = s + (Cos(3.1416 * (f + 1) / j)) ^ 2 ' FORMULA

Code: (Select All)
n = 3: Print n: p = 0 ' nijprime.bas Willans 1964
Dim f As Long
For i = 1 To 2 ^ n

    s = 0: Print: Print i;
    For j = 1 To i

        f = 1
        For g = 1 To j - 1
            f = f * g
        Next g: Print "  ="; f;

        s = s + (Cos(3.1416 * (f + 1) / j)) ^ 2 ' FORMULA
    Next j

    p = p + (n / s) ^ (1 / n)
Next i

p = 1 + p: Print: Print p


I create a version of my prime program about primes
in JavaScript where all numbers are long
by copying save HTM or checked online

https://jdoodle.com/h/2XK

Moreover results of BAS & JS are same

I think there is a mistake in formula

Code: (Select All)
<!DOCTYPE html> <html lang="en"> <head>
<title>nijprime js JavaScript DANILIN</title>
<html> <body>

https://jdoodle.com/h/2XK 

<script>

document.write("<br/> nijprime.bas Willans 1964")

n = 4; document.write("<br/>" + n); p = 0

for (i=1; i <= Math.pow(2,n); i++)

  { s = 0; document.write("<br/>" + i)

    for (j=1; j<=i; j++)

      { f = 1; for (g=1; g <= j-1; g++) f = f * g        
        document.write("  ="+ f)
        s = s + Math.pow((Math.cos(Math.PI * (f + 1) / j)),2)
      }

    p = p + Math.pow((n / s), (1 / n))
   }

p = 1 + p; document.write("<br/>" + p)

</script>

</body> </html>

4
16 =1 =1 =2 =6 =24 =120 =720 =5040 =40320 =362880 =3628800 =39916800 =479001600 =6227020800 =87178291200 =1307674368000
15.582928489000466


https://jdoodle.com/h/2XK

1001 prime is 104743

06-06-2022, 08:15 PM
https://qb64phoenix.com/forum/showthread...45#pid2945
long read
https://rosettacode.org/wiki/10001th_prime
Write name of program in 1st line to copy & paste & save filename.bas
Insert program pictures: press print-screen-shot button
Open paint & Paste & Save as PNG
Add picture file to program topic

Russia looks world from future. Big data is peace data.
I never recommend anything & always write only about myself
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: 15 Guest(s)