import math


def is_pentagonal(p: int) -> int:
    """
    P = n * (3n - 1) / 2

    If P is pentagonal, the above equation will have a positive integer solution
    for n. We use the quadratic formula to check if either solution for n is a
    positive integer
    """
    root = math.sqrt(24 * p + 1)
    return root.is_integer() and ((1 + root) / 6).is_integer()