Find the element at R ' th ▁ row ▁ and ▁ C ' th column in given a 2D pattern | Function to find the R ' th ▁ row ▁ and ▁ C ' th column value in the given pattern ; First element of a given row ; Element in the given column ; Driver Code ; Function call
def findValue ( R , C ) : NEW_LINE INDENT k = ( R * ( R - 1 ) ) // 2 + 1 NEW_LINE diff = R + 1 NEW_LINE for i in range ( 1 , C ) : NEW_LINE INDENT k = ( k + diff ) NEW_LINE diff += 1 NEW_LINE DEDENT return k NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT R = 4 NEW_LINE C = 4 NEW_LINE k = findValue ( R , C ) NEW_LINE print ( k ) NEW_LINE DEDENT