0 out of 464 challenges solved

Nth Hexagonal Number

A hexagonal number is a figurate number that represents a hexagon with a dot at each corner. The formula to calculate the nth hexagonal number is given by:

\[ H_n = n \times (2n - 1) \]

Write a function `hexagonal_num(n)` that takes an integer `n` as input and returns the nth hexagonal number.

#### Example Usage
```python [main.nopy]
hexagonal_num(1)  # Output: 1
hexagonal_num(2)  # Output: 6
hexagonal_num(3)  # Output: 15
hexagonal_num(10) # Output: 190
```
def hexagonal_num(n):
    """
    Calculate the nth hexagonal number.

    Args:
        n (int): The position of the hexagonal number to calculate.

    Returns:
        int: The nth hexagonal number.
    """
    # Implement the formula for the nth hexagonal number
    pass