A hexagonal number is a figurate number that can be represented by a regular hexagon. The n-th hexagonal number (starting from n = 1) is given by the formula: H_n = n * (2n - 1). The sequence begins 1, 6, 15, 28, 45, ...
Write a function `is_hexagonal(num)` that returns `True` if the given non-negative integer `num` is a hexagonal number, and `False` otherwise.
Your function must handle inputs up to 1,000,000 efficiently. Use a loop that incrementally computes hexagonal numbers until the value exceeds `num`.
Constraints
0 <= num <= 1,000,000
Time complexity O(sqrt(num)) or better.