Skip to content

Instantly share code, notes, and snippets.

@diogojorgebasso
Created May 15, 2022 17:12
Show Gist options
  • Save diogojorgebasso/2e6ce22e72e6270bc5b60b9c795a452e to your computer and use it in GitHub Desktop.
Save diogojorgebasso/2e6ce22e72e6270bc5b60b9c795a452e to your computer and use it in GitHub Desktop.
Proof of Bertrand's Theorem
# We know for sure based upon "M. El Bachraoui, Bertrand’s postulate for high–school students, International Journal of Mathematical Education, 9 (2019), 73–77" that the postulate is true for n>112.
# Therefore, it is necessary a proof by exhaustion until 113 - this is the porpouse of this Python's algorithm.
def isprime(n):
for num in range(2,n):
if (n%num)==0:
return False
return True
def validatetheorem(num):
for i in range(n, 2*n+1):
if isprime(i):
return True
for n in range(1,114):
if validatetheorem(n):
print(n, "is valid")
@diogojorgebasso
Copy link
Author

Bertrand's Postulate: Given a number, we know for sure that exists a p such that: n<= p <= 2n

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment