TheAlgorithms/Python · error · ValueError
The Denominator Cannot be less than 0
Error message
The Denominator Cannot be less than 0
What it means
Error "The Denominator Cannot be less than 0" thrown in TheAlgorithms/Python.
Source
Thrown at maths/numerical_analysis/proper_fractions.py:27
>>> proper_fractions(10)
['1/10', '3/10', '7/10', '9/10']
>>> proper_fractions(5)
['1/5', '2/5', '3/5', '4/5']
>>> proper_fractions(-15)
Traceback (most recent call last):
...
ValueError: The Denominator Cannot be less than 0
>>> proper_fractions(0)
[]
>>> proper_fractions(1.2)
Traceback (most recent call last):
...
ValueError: The Denominator must be an integer
"""
if denominator < 0:
raise ValueError("The Denominator Cannot be less than 0")
elif isinstance(denominator, float):
raise ValueError("The Denominator must be an integer")
return [
f"{numerator}/{denominator}"
for numerator in range(1, denominator)
if gcd(numerator, denominator) == 1
]
if __name__ == "__main__":
from doctest import testmod
testmod()
View on GitHub (pinned to f5988cc097)
Solutions
- Pass a denominator greater than 0.
When it happens
Trigger: Thrown at maths/numerical_analysis/proper_fractions.py:27 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of TheAlgorithms/Python@f5988cc097 (2026-08-14).
Data as JSON: /api/errors/310fa706d50fec0a.
Report an issue: GitHub.