X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;f=math_utils.py;fp=math_utils.py;h=56fb7072366ab97621e032e9aed11d13d7740b5e;hb=97fbe845e5dfdbda22521117c1783e1fd8515952;hp=2e126990fba0d7b9138f4a4b6238440aae89bb82;hpb=a838c154135b2420d9047a101caf24a2c9f593c2;p=python_utils.git diff --git a/math_utils.py b/math_utils.py index 2e12699..56fb707 100644 --- a/math_utils.py +++ b/math_utils.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 +import functools import math from typing import List from heapq import heappush, heappop @@ -60,6 +61,7 @@ def truncate_float(n: float, decimals: int = 2): return int(n * multiplier) / multiplier +@functools.lru_cache(maxsize=1024, typed=True) def is_prime(n: int) -> bool: """Returns True if n is prime and False otherwise""" if not isinstance(n, int):