{"record":{"id":"a1d0c757883938b4","repo":"TheAlgorithms/Python","slug":"input-value-of-number-must-be-0","errorCode":null,"errorMessage":"Input value of [{number=}] must be > 0","messagePattern":"Input value of \\[(.+?)\\] must be > 0","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"maths/special_numbers/proth_number.py","lineNumber":93,"sourceCode":"    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\n\n    doctest.testmod()\n\n    for number in range(11):","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/TheAlgorithms/Python/blob/f5988cc09713315817df6a7e327e258013a94440/maths/special_numbers/proth_number.py#L75-L111","documentation":"Raised by is_proth_number(number) when the argument is a builtin int but <= 0. The algorithm subtracts 1 and repeatedly divides by 2, which is undefined for inputs < 1 (and 1 is special-cased to return False just below this guard), so non-positive integers are rejected.","triggerScenarios":"Calling is_proth_number(0) or is_proth_number(-1). This fires only after the isinstance check passes; non-integers raise the TypeError above.","commonSituations":"Screening raw user input or sensor values that can be 0/negative without pre-filtering; iterating a range that includes 0.","solutions":["Filter candidates to >= 1 before calling (or >= 2, since 1 returns False anyway)","Validate user-supplied candidates at your boundary","Treat non-positive inputs as 'not a Proth number' in your own wrapper before delegating"],"exampleFix":"// before\nok = is_proth_number(-1)  # ValueError\n\n// after\nok = is_proth_number(25)","handlingStrategy":"validation","validationCode":"if n < 1:\n    ok = False  # non-positives are simply not Proth numbers\nelse:\n    ok = is_proth_number(n)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Filter candidates to >= 1 before screening","1 returns False without raising — only <= 0 raises","Validate user-supplied candidate lists up front"],"tags":["math","valueerror","input-validation","proth"],"backgroundTag":null,"analyzedSha":"f5988cc09713315817df6a7e327e258013a94440","analyzedAt":"2026-08-14T17:30:07.041Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}