0 out of 464 challenges solved

Nth Octagonal Number

An octagonal number is a figurate number that represents an octagon. The formula to calculate the nth octagonal number is given by:

\[ O_n = 3n^2 - 2n \]

Write a Python function `nth_octagonal_number(n: int) -> int` that takes an integer `n` and returns the nth octagonal number.

#### Example Usage
```python [main.nopy]
print(nth_octagonal_number(1))  # Output: 1
print(nth_octagonal_number(5))  # Output: 65
print(nth_octagonal_number(10)) # Output: 280
```

#### Constraints
- The input `n` will be a positive integer.
- The function should return the result as an integer.
def nth_octagonal_number(n: int) -> int:
    """
    Calculate the nth octagonal number.

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

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