```python
def is_octagonal(n):
    """
    Calculates the nth octagonal number.
    The formula for the nth octagonal number is n * (3n - 2).
    """
    return n * (3 * n - 2)

```