Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- def lessthan(a, b, c, d):
- """Is a/b < c/d?"""
- return a * d < b * c
- n = 10000000
- squares = {i * i for i in range(2, int(math.sqrt(n + 1)))}
- square_frees = [1 for i in range(n + 1)]
- for i in range(0, n + 1):
- if i in squares and square_frees[i] == 1:
- for j in range(i, n + 1, i):
- square_frees[j] = 0
- square_frees[0] = 0
- a, b = 1000000000, 1
- A, B = 106, 176
- for i in range(1, n + 1):
- square_frees[i] += square_frees[i - 1]
- if lessthan(square_frees[i], i, a, b):
- a, b = square_frees[i], i
- #print("i = {}, ratio = {}".format(i, square_frees[i] / i))
- print("lowest ratio: {}/{} = {} from i = {}".format(a, b, a / b, b))
- print("comparing with {}/{} = {}".format(A, B, A / B))
- if lessthan(a, b, A, B):
- print("counterexample found")
- else:
- print("no counterexample")
Add Comment
Please, Sign In to add comment