File tree 1 file changed +2
-3
lines changed
1 file changed +2
-3
lines changed Original file line number Diff line number Diff line change 1
- import doctest
2
1
from math import gcd
3
2
4
3
5
4
def proper_fractions (denominator : int ) -> list [str ]:
6
5
"""
7
6
this algorithm returns a list of proper fractions, in the
8
7
range between 0 and 1, which can be formed with the given denominator
9
- proper fractions: https://en.wikipedia.org/wiki/Fraction#:~:text=Proper%20and%20improper,and%203/3.
8
+ https://en.wikipedia.org/wiki/Fraction#Proper_and_improper_fractions
10
9
11
10
>>> proper_fractions(10)
12
11
['1/10', '3/10', '7/10', '9/10']
@@ -25,7 +24,7 @@ def proper_fractions(denominator: int) -> list[str]:
25
24
if denominator < 0 :
26
25
raise ValueError ("The Denominator Cannot be less than 0" )
27
26
elif isinstance (denominator , float ):
28
- raise ValueError ("The Denominator has to be an integer" )
27
+ raise ValueError ("The Denominator must be an integer" )
29
28
return [
30
29
f"{ numerator } /{ denominator } "
31
30
for numerator in range (1 , denominator )
You can’t perform that action at this time.
0 commit comments