Created
December 21, 2019 21:33
-
-
Save emukupa/7ef2e8567c27337b43b94e94fcaf4e39 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import mersenneSequence from "./mersenne_sequence"; | |
| import isPrime from "./isPrime"; | |
| const max: number = 100; | |
| // warning: this takes a long time to run?? you have been warned!! | |
| for (let n = 1; n < max; n++) { | |
| let primeCount: number = 0; | |
| const mList: number[] = mersenneSequence(n); | |
| mList.forEach(num => { | |
| if (isPrime(num)) { | |
| primeCount++; | |
| } | |
| }); | |
| //console.log(mList.length); | |
| //console.log(primeCount); | |
| console.log(primeCount / mList.length * 100); // to compare with 100% of mersenne numbers | |
| } | |
| /* | |
| 0 | |
| 33.33333333333333 | |
| 50 | |
| 40 | |
| 50 | |
| 42.857142857142854 | |
| 50 | |
| 44.44444444444444 | |
| 40 | |
| 36.36363636363637 | |
| 33.33333333333333 | |
| 30.76923076923077 | |
| 35.714285714285715 | |
| 33.33333333333333 | |
| 31.25 | |
| 29.411764705882355 | |
| 33.33333333333333 | |
| 31.57894736842105 | |
| 35 | |
| 33.33333333333333 | |
| 31.818181818181817 | |
| 30.434782608695656 | |
| 29.166666666666668 | |
| 28.000000000000004 | |
| 26.923076923076923 | |
| 25.925925925925924 | |
| 25 | |
| 24.137931034482758 | |
| 23.333333333333332 | |
| 22.58064516129032 | |
| 25 | |
| 24.242424242424242 | |
| 23.52941176470588 | |
| 22.857142857142858 | |
| 22.22222222222222 | |
| 21.62162162162162 | |
| 21.052631578947366 | |
| 20.51282051282051 | |
| 20 | |
| 19.51219512195122 | |
| 19.047619047619047 | |
| 18.6046511627907 | |
| 18.181818181818183 | |
| 17.77777777777778 | |
| 17.391304347826086 | |
| 17.02127659574468 | |
| 16.666666666666664 | |
| 16.3265306122449 | |
| 16 | |
| 15.686274509803921 | |
| 15.384615384615385 | |
| 15.09433962264151 | |
| 14.814814814814813 | |
| 14.545454545454545 | |
| 14.285714285714285 | |
| 14.035087719298245 | |
| 13.793103448275861 | |
| 13.559322033898304 | |
| 13.333333333333334 | |
| 13.114754098360656 | |
| 12.903225806451612 | |
| 12.698412698412698 | |
| 12.5 | |
| 12.307692307692308 | |
| 12.121212121212121 | |
| 11.940298507462686 | |
| 11.76470588235294 | |
| 11.594202898550725 | |
| 11.428571428571429 | |
| 11.267605633802818 | |
| 11.11111111111111 | |
| 10.95890410958904 | |
| 10.81081081081081 | |
| 10.666666666666668 | |
| 10.526315789473683 | |
| 10.38961038961039 | |
| 10.256410256410255 | |
| 10.126582278481013 | |
| 10 | |
| 9.876543209876543 | |
| 9.75609756097561 | |
| 9.63855421686747 | |
| 9.523809523809524 | |
| 9.411764705882353 | |
| 9.30232558139535 | |
| 9.195402298850574 | |
| 9.090909090909092 | |
| 8.98876404494382 | |
| 8.88888888888889 | |
| 8.791208791208792 | |
| 8.695652173913043 | |
| 8.60215053763441 | |
| 8.51063829787234 | |
| 8.421052631578947 | |
| 8.333333333333332 | |
| 8.24742268041237 | |
| 8.16326530612245 | |
| 8.080808080808081 | |
| 8 | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment