Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from fractions import *
- from time import *
- def solve(p, q):
- rem = Fraction(p, q)
- answ = []
- fact = 1
- count = 1;
- while rem != 0:
- count += 1
- fact *= count
- num = rem.numerator * fact // rem.denominator
- rem = rem - Fraction(num, fact)
- answ.append(num)
- return answ
- #answ = solve(1, 5)
- #print(len(answ)+1)
- #for t in answ: print(t)
- mt, mp, mq = 0,0,0
- for p in range(1, 999):
- for q in range(p+1, 1000):
- st = clock();
- answ = solve(p, q);
- t = clock()-st;
- if (t >= mt):
- mp, mq, mt = p, q, t
- print("time(s) = ", mt, "p = ", p, "q = ", q);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement