Skip to main content

arithmetic_sum

Function arithmetic_sum 

pub const fn arithmetic_sum(
    first: i128,
    step: i128,
    terms: u64,
) -> Result<i128, SeriesError>
Expand description

Returns the sum of the first terms values of an arithmetic progression.

§Errors

Returns SeriesError::Overflow when the partial sum does not fit in i128.

§Examples

use use_series::arithmetic_sum;

assert_eq!(arithmetic_sum(3, 2, 5)?, 35);