1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use ;
/// Calculates the nth hexagonal number.
///
/// # Arguments
///
/// * `n` - A non-negative integer representing the position in the hexagonal sequence.
///
/// # Returns
///
/// The nth hexagonal number .
///
/// # Examples
///
/// ```
/// use numberlab::figurate::hexagonal::nth_hexagonal;
///
/// let result = nth_hexagonal(10);
/// assert_eq!(result, 190);
/// ```
/// Generates a sequence of hexagonal numbers up to the given number `n`.
///
/// # Arguments
///
/// * `n` - A non-negative integer representing the number of terms in the hexagonal sequence.
///
/// # Returns
///
/// A vector containing the hexagonal sequence up to the given number `n`.
///
/// # Examples
///
/// ```
/// use numberlab::figurate::hexagonal::hexagonal_sequence;
///
/// let sequence = hexagonal_sequence(5);
/// assert_eq!(sequence, vec![0, 1, 6, 15, 28]);
/// ```