Find the element at R ' th ▁ row ▁ and ▁ C ' th column in given a 2D pattern | Function to compute the R ' th ▁ row ▁ and ▁ C ' th column of the given pattern ; First element of a given row ; Element in the given column ; Driver Code ; Function call
function findValue ( R , C ) { let k = ( R * ( R - 1 ) ) / 2 + 1 ; let diff = R + 1 ; for ( let i = 1 ; i < C ; i ++ ) { k = ( k + diff ) ; diff ++ ; } return k ; } let R = 4 ; let C = 4 ; let k = findValue ( R , C ) ; document . write ( k ) ;