We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0dacfdf commit a53236aCopy full SHA for a53236a
project_euler/problem_97/sol1.py
@@ -15,17 +15,24 @@ def compute_digits(n: int) -> str:
15
Returns the last n digits of NUMBER.
16
>>> compute_digits(10)
17
'8740021009'
18
+ >>> compute_digits(8)
19
+ '40021009'
20
+ >>> compute_digits(1)
21
+ '9'
22
>>> compute_digits(-1)
- -1
23
+ ''
24
>>> compute_digits(8.3)
25
26
"""
27
if n < 0 or not isinstance(n, int):
- return -1
28
+ return ''
29
MODULUS = 10 ** n
30
NUMBER = 28433 * (pow(2, 7830457, MODULUS) + 1)
31
return str(NUMBER % MODULUS)
32
33
34
if __name__ == "__main__":
35
+ from doctest import testmod
36
+
37
+ testmod()
38
print(f"{compute_digits(10)}")
0 commit comments