Skip to content

Commit a53236a

Browse files
authored
Update sol1.py
1 parent 0dacfdf commit a53236a

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

project_euler/problem_97/sol1.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,24 @@ def compute_digits(n: int) -> str:
1515
Returns the last n digits of NUMBER.
1616
>>> compute_digits(10)
1717
'8740021009'
18+
>>> compute_digits(8)
19+
'40021009'
20+
>>> compute_digits(1)
21+
'9'
1822
>>> compute_digits(-1)
19-
-1
23+
''
2024
>>> compute_digits(8.3)
21-
-1
25+
''
2226
"""
2327
if n < 0 or not isinstance(n, int):
24-
return -1
28+
return ''
2529
MODULUS = 10 ** n
2630
NUMBER = 28433 * (pow(2, 7830457, MODULUS) + 1)
2731
return str(NUMBER % MODULUS)
2832

2933

3034
if __name__ == "__main__":
35+
from doctest import testmod
36+
37+
testmod()
3138
print(f"{compute_digits(10)}")

0 commit comments

Comments
 (0)