Find N Arithmetic Means between A and B | Prints N arithmetic means between A and B . ; calculate common difference ( d ) ; for finding N the arithmetic mean between A and B ; Driver Code
< ? php function printAMeans ( $ A , $ B , $ N ) { $ d = ( $ B - $ A ) / ( $ N + 1 ) ; for ( $ i = 1 ; $ i <= $ N ; $ i ++ ) echo ( $ A + $ i * $ d ) , " ▁ " ; } $ A = 20 ; $ B = 32 ; $ N = 5 ; printAMeans ( $ A , $ B , $ N ) ; ? >