import math


def rev_pentagonal(n):
    """Reverse pentagonal. Return 0 for n < 0 or negate result is if is not positive integer result."""
    if n < 0:
        return 0
    delta = int(math.sqrt(1 + 24 * n))
    # delta is square and 1 + 24 * n % 6 == 0 so delta %6 == 5
    if delta * delta == 1 + 24 * n and delta % 6 == 5:
        return (delta + 1) // 6
    else:
        return - (delta + 1) // 6