|
33 | 33 | from math import sqrt, factorial |
34 | 34 | import random |
35 | 35 | import itertools |
36 | | -from typing import Union, Literal |
| 36 | +from typing import Union, Tuple, List |
37 | 37 |
|
38 | 38 | fact = (1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880) |
39 | 39 |
|
@@ -169,7 +169,7 @@ def fibonacci(n: int): |
169 | 169 | return _fib(n)[0] |
170 | 170 |
|
171 | 171 |
|
172 | | -def _fib(n: int) -> tuple[int, int]: |
| 172 | +def _fib(n: int) -> Tuple[int, int]: |
173 | 173 | '''Returns a tuple of fibonacci (F(n), F(n+1)).''' |
174 | 174 | if n == 0: |
175 | 175 | return (0, 1) |
@@ -275,7 +275,7 @@ def _miller_rabin_pass(a: int, s: int, f: int, n: int): |
275 | 275 | return a_to_power == n - 1 |
276 | 276 |
|
277 | 277 |
|
278 | | -def factor(n: int) -> list[tuple[int, int]]: |
| 278 | +def factor(n: int) -> List[Tuple[int, int]]: |
279 | 279 | """ |
280 | 280 | Find the prime factors of a given number along with their frequencies. |
281 | 281 | Args: |
@@ -477,9 +477,7 @@ def miu(x: int): |
477 | 477 |
|
478 | 478 | #source: |
479 | 479 | # http://interactivepython.org/runestone/static/pythonds/Recursion/pythondsConvertinganIntegertoaStringinAnyBase.html |
480 | | -def dec2base( |
481 | | - n: int, base: Literal[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, |
482 | | - 16]) -> str: |
| 480 | +def dec2base(n: int, base: int) -> str: |
483 | 481 | """ |
484 | 482 | Convert a decimal number to a specified base. |
485 | 483 | Args: |
@@ -520,7 +518,7 @@ def n2words(num: int, join: bool = True): |
520 | 518 | 'Tredecillion','Quattuordecillion','Sexdecillion', \ |
521 | 519 | 'Septendecillion','Octodecillion','Novemdecillion', \ |
522 | 520 | 'Vigintillion'] |
523 | | - words: list[str] = [] |
| 521 | + words: List[str] = [] |
524 | 522 | if num == 0: |
525 | 523 | words.append('zero') |
526 | 524 | else: |
|
0 commit comments