{"record":{"id":"c32379ba8ea2978f","repo":"TheAlgorithms/Python","slug":"input-value-of-number-number-must-be-an-intege-c32379","errorCode":null,"errorMessage":"Input value of [number={number}] must be an integer","messagePattern":"Input value of \\[number=(.+?)\\] must be an integer","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"maths/special_numbers/proth_number.py","lineNumber":33,"sourceCode":"    >>> proth(6)\n    25\n    >>> proth(0)\n    Traceback (most recent call last):\n        ...\n    ValueError: Input value of [number=0] must be > 0\n    >>> proth(-1)\n    Traceback (most recent call last):\n        ...\n    ValueError: Input value of [number=-1] must be > 0\n    >>> proth(6.0)\n    Traceback (most recent call last):\n        ...\n    TypeError: Input value of [number=6.0] must be an integer\n    \"\"\"\n\n    if not isinstance(number, int):\n        msg = f\"Input value of [number={number}] must be an integer\"\n        raise TypeError(msg)\n\n    if number < 1:\n        msg = f\"Input value of [number={number}] must be > 0\"\n        raise ValueError(msg)\n    elif number == 1:\n        return 3\n    elif number == 2:\n        return 5\n    else:\n        \"\"\"\n        +1 for binary starting at 0 i.e. 2^0, 2^1, etc.\n        +1 to start the sequence at the 3rd Proth number\n        Hence, we have a +2 in the below statement\n        \"\"\"\n        block_index = int(math.log(number // 3, 2)) + 2\n\n        proth_list = [3, 5]\n        proth_index = 2","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/TheAlgorithms/Python/blob/f5988cc09713315817df6a7e327e258013a94440/maths/special_numbers/proth_number.py#L15-L51","documentation":"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.","triggerScenarios":"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.","commonSituations":"Sequence indices computed from float math (e.g. results of / instead of //); deserialized JSON numbers that arrive as floats.","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"],"exampleFix":"// before\np = proth(6.0)  # TypeError\n\n// after\np = proth(int(6.0))","handlingStrategy":"type-guard","validationCode":"if not isinstance(n, int) or isinstance(n, bool):\n    n = int(n)\np = proth(n)","typeGuard":"def is_builtin_int(v) -> TypeGuard[int]:\n    return isinstance(v, int) and not isinstance(v, bool)","tryCatchPattern":"try:\n    p = proth(n)\nexcept TypeError:\n    p = proth(int(n))","preventionTips":["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"],"tags":["math","typeerror","type-checking","proth"],"backgroundTag":null,"analyzedSha":"f5988cc09713315817df6a7e327e258013a94440","analyzedAt":"2026-08-14T17:30:07.041Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}