Created
June 3, 2023 13:39
-
-
Save Hermann-SW/362858051f7b7a850c163cd5144256c3 to your computer and use it in GitHub Desktop.
Determinine percentages of "is_prime(f_x(p))" with "f_x(p) = round_to_odd(p * x)"
This file contains 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
# pylint:disable=C0103, C0114, C0116, W0611 | |
from math import sqrt, floor, pi, e | |
from sympy import nextprime, isprime | |
def digits(n): | |
return len(str(n)) | |
phi = (sqrt(5) + 1) / 2 | |
def f(n): | |
assert isprime(n) | |
x = floor(phi * n) # * e # * pi | |
return x if x % 2 else x + 1 | |
def out(b): | |
print(b[0] + b[1], b, b[1] / (b[0] + b[1])) | |
def doit(end): | |
l = 1 | |
b = [0, 0] | |
p = 2 | |
while p <= end: | |
y = int(isprime(f(p))) | |
b[y] = b[y] + 1 | |
l = p | |
p = nextprime(p) | |
if digits(p) > digits(l): | |
out(b) | |
out(b) | |
doit(100000000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Followup of:
https://twitter.com/HermannSW/status/1664928016407953408
"multiplicative twin primes" wrt "round_to_odd()" occur quite often for irrational numbers phi/e/pi: