TheAlgorithms/Python · error · TypeError
Input value of [number={number}] must be an integer
Error message
Input value of [number={number}] must be an integer What it means
Raised by proth(number) in maths/special_numbers/proth_number.py when the argument is not an int. The function returns the n-th Proth number (3, 5, 13, 17, ...) computed via log2 block indexing, which requires an exact integer index, so floats like 6.0 are rejected before any math runs.
Source
Thrown at maths/special_numbers/proth_number.py:33
>>> proth(6)
25
>>> proth(0)
Traceback (most recent call last):
...
ValueError: Input value of [number=0] must be > 0
>>> proth(-1)
Traceback (most recent call last):
...
ValueError: Input value of [number=-1] must be > 0
>>> proth(6.0)
Traceback (most recent call last):
...
TypeError: Input value of [number=6.0] must be an integer
"""
if not isinstance(number, int):
msg = f"Input value of [number={number}] must be an integer"
raise TypeError(msg)
if number < 1:
msg = f"Input value of [number={number}] must be > 0"
raise ValueError(msg)
elif number == 1:
return 3
elif number == 2:
return 5
else:
"""
+1 for binary starting at 0 i.e. 2^0, 2^1, etc.
+1 to start the sequence at the 3rd Proth number
Hence, we have a +2 in the below statement
"""
block_index = int(math.log(number // 3, 2)) + 2
proth_list = [3, 5]
proth_index = 2View on GitHub (pinned to f5988cc097)
Solutions
- Convert integral values explicitly: proth(int(x))
- Keep sequence indices in integer arithmetic (use // not /)
- Reject non-int indices at your own API boundary
Example fix
// before p = proth(6.0) # TypeError // after p = proth(int(6.0))
Defensive patterns
Strategy: type-guard
Validate before calling
if not isinstance(n, int) or isinstance(n, bool):
n = int(n)
p = proth(n) Type guard
def is_builtin_int(v) -> TypeGuard[int]:
return isinstance(v, int) and not isinstance(v, bool) Try / catch
try:
p = proth(n)
except TypeError:
p = proth(int(n)) Prevention
- Use // not / when computing sequence indices
- Convert JSON floats to int on load
- The type check fires before the range check — fix types first when debugging
When it happens
Trigger: Calling proth(6.0), proth('3'), or proth(None). This TypeError fires before the range check, so proth(-1) raises the ValueError about > 0 instead.
Common situations: Sequence indices computed from float math (e.g. results of / instead of //); deserialized JSON numbers that arrive as floats.
Related errors
- Input value of [{number=}] must be an integer
- Input value of [number={number}] must be an integer
- Input value of [number={number}] must be an integer
- Input value of [number={number}] must be an integer
- Useful years must be an integer
AI-assisted analysis of TheAlgorithms/Python@f5988cc097 (2026-08-14).
Data as JSON: /api/errors/c32379ba8ea2978f.
Report an issue: GitHub.