{"record":{"id":"dda4875ae2d33ae5","repo":"TheAlgorithms/Python","slug":"input-value-of-number-number-must-be-0-dda487","errorCode":null,"errorMessage":"Input value of [number={number}] must be > 0","messagePattern":"Input value of \\[number=(.+?)\\] must be > 0","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"maths/special_numbers/proth_number.py","lineNumber":37,"sourceCode":"        ...\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\n        increment = 3\n        for block in range(1, block_index):\n            for _ in range(increment):\n                proth_list.append(2 ** (block + 1) + proth_list[proth_index - 1])","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/TheAlgorithms/Python/blob/f5988cc09713315817df6a7e327e258013a94440/maths/special_numbers/proth_number.py#L19-L55","documentation":"Raised by proth(number) when the argument is an int but less than 1. The Proth sequence is 1-indexed (proth(1) == 3, proth(2) == 5, then log-based indexing for n >= 3), so 0 and negative indices are meaningless and rejected after the type check.","triggerScenarios":"Calling proth(0) or proth(-1). Non-integers raise the TypeError first; this ValueError only fires for builtin ints below 1.","commonSituations":"0-based loops (`range(0, n)`) feeding a 1-based sequence API; computing an index that can go to 0 or negative on degenerate input (empty list -> idx 0).","solutions":["Shift 0-based indices by one: proth(i + 1)","Loop from 1: `for i in range(1, n + 1)`","Clamp or validate computed indices to >= 1 before calling"],"exampleFix":"// before\np = proth(0)  # ValueError\n\n// after\np = proth(1)  # first Proth number, 3","handlingStrategy":"validation","validationCode":"if n < 1:\n    raise IndexError('proth is 1-indexed; got %r' % n)\np = proth(n)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["proth(1) is the first term (3) — 1-based API","Shift 0-based loops with i + 1","Guard computed indices against degenerate inputs (empty sequences)"],"tags":["math","valueerror","input-validation","off-by-one","proth"],"backgroundTag":null,"analyzedSha":"f5988cc09713315817df6a7e327e258013a94440","analyzedAt":"2026-08-14T17:30:07.041Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}