Sum of matrix element where each elements is integer division of row and column | Return sum of matrix element where each element is division of its corresponding row and column . ; For each column . ; count the number of elements of each column . Initialize to i - 1 because number of zeroes are i - 1. ; For multiply ; Driver Code
< ? php function findSum ( $ n ) { $ ans = 0 ; $ temp = 0 ; $ num ; for ( $ i = 1 ; $ i <= $ n and $ temp < $ n ; $ i ++ ) { $ temp = $ i - 1 ; $ num = 1 ; while ( $ temp < $ n ) { if ( $ temp + $ i <= $ n ) $ ans += ( $ i * $ num ) ; else $ ans += ( ( $ n - $ temp ) * $ num ) ; $ temp += $ i ; $ num ++ ; } } return $ ans ; } $ N = 2 ; echo findSum ( $ N ) ; ? >