{"record":{"id":"4a544dd4abd838a1","repo":"TheAlgorithms/Python","slug":"input-value-of-number-must-be-an-integer","errorCode":null,"errorMessage":"Input value of [{number=}] must be an integer","messagePattern":"Input value of \\[(.+?)\\] must be an integer","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"maths/special_numbers/proth_number.py","lineNumber":89,"sourceCode":"    True\n    >>> is_proth_number(4)\n    False\n    >>> is_proth_number(5)\n    True\n    >>> is_proth_number(34)\n    False\n    >>> is_proth_number(-1)\n    Traceback (most recent call last):\n        ...\n    ValueError: Input value of [number=-1] must be > 0\n    >>> is_proth_number(6.0)\n    Traceback (most recent call last):\n        ...\n    TypeError: Input value of [number=6.0] must be an integer\n    \"\"\"\n    if not isinstance(number, int):\n        message = f\"Input value of [{number=}] must be an integer\"\n        raise TypeError(message)\n\n    if number <= 0:\n        message = f\"Input value of [{number=}] must be > 0\"\n        raise ValueError(message)\n\n    if number == 1:\n        return False\n\n    number -= 1\n    n = 0\n    while number % 2 == 0:\n        n += 1\n        number //= 2\n    return number < 2**n\n\n\nif __name__ == \"__main__\":\n    import doctest","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/TheAlgorithms/Python/blob/f5988cc09713315817df6a7e327e258013a94440/maths/special_numbers/proth_number.py#L71-L107","documentation":"Raised by is_proth_number(number) in maths/special_numbers/proth_number.py when the argument is not an int. The predicate factors out powers of 2 from number-1, which requires exact integer arithmetic, so floats like 6.0 (and strings, None, etc.) are rejected up front. Note the message uses the {number=} self-documenting f-string format, e.g. 'Input value of [number=6.0] must be an integer'.","triggerScenarios":"Calling is_proth_number(6.0), is_proth_number('7'), or is_proth_number(None). The type check precedes the range check, so 0/-1 raise the ValueError instead.","commonSituations":"Float-typed candidates from divisions or JSON; numpy scalars; generic pipelines that forward unchecked values to math predicates.","solutions":["Coerce integral floats: is_proth_number(int(x)) when x.is_integer()","Keep candidates in integer arithmetic end-to-end","Add an isinstance(n, int) guard at your boundary with a domain-specific message"],"exampleFix":"// before\nis_proth_number(6.0)  # TypeError\n\n// after\nis_proth_number(int(6.0))","handlingStrategy":"type-guard","validationCode":"if not isinstance(n, int) or isinstance(n, bool):\n    n = int(n)\nprint(is_proth_number(n))","typeGuard":"def is_builtin_int(v) -> TypeGuard[int]:\n    return isinstance(v, int) and not isinstance(v, bool)","tryCatchPattern":"try:\n    is_proth_number(n)\nexcept TypeError:\n    is_proth_number(int(n))","preventionTips":["Coerce integral floats before calling","Keep candidate pipelines integer-only","Message format differs from proth() ({number=} vs {number=}) — match on 'must be an integer', not exact strings, if you parse it"],"tags":["math","typeerror","type-checking","proth"],"backgroundTag":null,"analyzedSha":"f5988cc09713315817df6a7e327e258013a94440","analyzedAt":"2026-08-14T17:30:07.041Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}