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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
use ;
/// Calculates the nth term of an arithmetic sequence.
///
/// # Arguments
///
/// * `a` - The first term of the sequence.
/// * `d` - The common difference between terms.
/// * `n` - The term number to calculate (must be greater than 0).
///
/// # Panics
///
/// Panics if `n` is 0.
///
/// # Examples
///
/// ```
/// use numberlab::sequence::arithmetic::nth_arithmetic;
/// let term = nth_arithmetic(1.0, 1.0, 5);
/// assert_eq!(term, 5.0);
/// ```
///
/// ```
/// use numberlab::sequence::arithmetic::nth_arithmetic;
/// let term = nth_arithmetic::<i32>(2, 3, 4);
/// assert_eq!(term, 11);
/// ```
/// Generates an arithmetic sequence.
///
/// # Arguments
///
/// * `a` - The first term of the sequence.
/// * `d` - The common difference between terms.
/// * `n` - The number of terms to generate (must be greater than 0).
///
/// # Examples
///
/// ```
/// use numberlab::sequence::arithmetic::arithmetic_sequence;
/// let sequence = arithmetic_sequence(1.0, 1.0, 5);
/// assert_eq!(sequence, vec![1.0, 2.0, 3.0, 4.0, 5.0]);
/// ```
///
/// ```
/// use numberlab::sequence::arithmetic::arithmetic_sequence;
/// let sequence = arithmetic_sequence::<i32>(2, 3, 4);
/// assert_eq!(sequence, vec![2, 5, 8, 11]);
/// ```
/// Calculates the sum of the first `n` terms of an arithmetic sequence.
///
/// # Arguments
///
/// * `a` - The first term of the sequence.
/// * `d` - The common difference between terms.
/// * `n` - The number of terms to sum (must be greater than 0).
///
/// # Returns
///
/// The sum of the first `n` terms of the arithmetic sequence.
///
/// # Examples
///
/// ```
/// use numberlab::sequence::arithmetic::arithmetic_series;
/// let sum = arithmetic_series(1.0, 1.0, 5);
/// assert_eq!(sum, 15.0);
/// ```
///
/// ```
/// use numberlab::sequence::arithmetic::arithmetic_series;
/// let sum = arithmetic_series::<i32>(2, 3, 4);
/// assert_eq!(sum, 26);
/// ```