Find the sum of n terms in an arithmetic progression. >>> sum_of_series(1, 1, 10) 55.0 >>> sum_of_series(1, 10, 100) 49600.0
(first_term: int, common_diff: int, num_of_terms: int)
| 1 | # DarkCoder |
| 2 | def sum_of_series(first_term: int, common_diff: int, num_of_terms: int) -> float: |
| 3 | """ |
| 4 | Find the sum of n terms in an arithmetic progression. |
| 5 | |
| 6 | >>> sum_of_series(1, 1, 10) |
| 7 | 55.0 |
| 8 | >>> sum_of_series(1, 10, 100) |
| 9 | 49600.0 |
| 10 | """ |
| 11 | total = (num_of_terms / 2) * (2 * first_term + (num_of_terms - 1) * common_diff) |
| 12 | # formula for sum of series |
| 13 | return total |
| 14 | |
| 15 | |
| 16 | def main(): |