public static bool IsTriangle(long n) { double upper = ((-1 + Math.Sqrt(1 + 8 * n)) / 2); return(FloatingPointEquals.IsEqualToLongWithPrecision(upper, (long)upper, 5)); }
public static bool IsSquare(long n) { double upper = (Math.Sqrt(n)); return(FloatingPointEquals.IsEqualToLongWithPrecision(upper, (long)upper, 5)); }
public static bool IsHexagonal(long n) { double upper = ((1 + Math.Sqrt(1 + 8 * n)) / 4); return(FloatingPointEquals.IsEqualToLongWithPrecision(upper, (long)upper, 5)); }