import math


def is_pentagonal(n):
    """
    According to Wikipedia, to test whether a positive integer x
    is a pentagonal number you can check that
    n = ((sqrt(24*x) + 1) + 1)//6 is a natural number.

    The number x is pentagonal if and only if n is a natural number.

    Source: https://stackoverflow.com/questions/
    37390233/python-is-pentagonal-number-check

    :param n:
    :return:
    """

    digit = (math.sqrt(24 * n + 1) + 1) / 6
    return digit.is_integer()