Program for sum of arithmetic series | Efficient PHP code to find sum of arithmetic series . ; Driver code
< ? php function sumOfAP ( $ a , $ d , $ n ) { $ sum = ( $ n / 2 ) * ( 2 * $ a + ( $ n - 1 ) * $ d ) ; return $ sum ; } $ n = 20 ; $ a = 2.5 ; $ d = 1.5 ; echo ( sumOfAP ( $ a , $ d , $ n ) ) ; ? >