Program for sum of arithmetic series | Efficient solution to find sum of arithmetic series . ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; float sumOfAP ( float a , float d , float n ) { float sum = ( n / 2 ) * ( 2 * a + ( n - 1 ) * d ) ; return sum ; } int main ( ) { float n = 20 ; float a = 2.5 , d = 1.5 ; cout << sumOfAP ( a , d , n ) ; return 0 ; }