def Stress_Test(N): while True: a = random.randint(1, N) b = random.randint(1, N) print(a, b) faster_lcm_n = faster_lcm(a, b) lcm_naive_n = lcm_naive(a, b) if faster_lcm_n == lcm_naive_n: print("OK!") else: assert faster_lcm_n == lcm_naive_n, f"{faster_lcm_n}, {lcm_naive_n}"
def test_small(self): for (a, b) in product(range(1, 15), repeat=2): self.assertEqual(lcm(a, b), lcm_naive(a, b))
import numpy as np from lcm import lcm_naive from lcm_fast import lcm_new import time while True: a = np.random.random_integers(0, 10000) b = np.random.random_integers(0, 10000) lcmold = lcm_naive(a, b) srt = time.time() lcmnew = lcm_new(a, b) end = time.time() print(a, '\t', b, '\t') if lcmold == lcmnew: print('OK \t', (end - srt), '\n') else: print('actual =', lcmold, '\touput =', lcmnew) print('\n FAIL') break