import math


def isTriangleNum(n):
    """Tests if n is a triangle number."""
    d = 1 + 8 * n;
    if d < 0:
        return False
    x1 = (math.sqrt(d) - 1) / 2;
    return x1 >= 0.0 and x1 == math.floor(x1);