# doctest: +NORMALIZE_WHITESPACE This functions takes an integer number as input. returns True if the number is pronic. >>> is_pronic(-1) False >>> is_pronic(0) True >>> is_pronic(2) True >>> is_pronic(5) False >>> is_pronic(6) True >>> is_pro
(number: int)
| 11 | |
| 12 | |
| 13 | def is_pronic(number: int) -> bool: |
| 14 | """ |
| 15 | # doctest: +NORMALIZE_WHITESPACE |
| 16 | This functions takes an integer number as input. |
| 17 | returns True if the number is pronic. |
| 18 | >>> is_pronic(-1) |
| 19 | False |
| 20 | >>> is_pronic(0) |
| 21 | True |
| 22 | >>> is_pronic(2) |
| 23 | True |
| 24 | >>> is_pronic(5) |
| 25 | False |
| 26 | >>> is_pronic(6) |
| 27 | True |
| 28 | >>> is_pronic(8) |
| 29 | False |
| 30 | >>> is_pronic(30) |
| 31 | True |
| 32 | >>> is_pronic(32) |
| 33 | False |
| 34 | >>> is_pronic(2147441940) |
| 35 | True |
| 36 | >>> is_pronic(9223372033963249500) |
| 37 | True |
| 38 | >>> is_pronic(6.0) |
| 39 | Traceback (most recent call last): |
| 40 | ... |
| 41 | TypeError: Input value of [number=6.0] must be an integer |
| 42 | """ |
| 43 | if not isinstance(number, int): |
| 44 | msg = f"Input value of [number={number}] must be an integer" |
| 45 | raise TypeError(msg) |
| 46 | if number < 0 or number % 2 == 1: |
| 47 | return False |
| 48 | number_sqrt = int(number**0.5) |
| 49 | return number == number_sqrt * (number_sqrt + 1) |
| 50 | |
| 51 | |
| 52 | if __name__ == "__main__": |
nothing calls this directly
no outgoing calls
no test coverage detected