Find count of occurrences of each prime factor
mp = { } ; NEW_LINE row_no = 0 ; max_factor = 0 ; NEW_LINE for i in range ( N ) : NEW_LINE INDENT for j in range ( M ) : NEW_LINE INDENT no = arr [ i ] [ j ] NEW_LINE for k in range ( len ( prime ) ) : NEW_LINE INDENT while ( no > 1 and no % prime [ k ] == 0 ) : NEW_LINE INDENT no //= prime [ k ] ; NEW_LINE if prime [ k ] not in mp : NEW_LINE INDENT mp [ prime [ k ] ] = 0 NEW_LINE DEDENT mp [ prime [ k ] ] += 1 ; NEW_LINE DEDENT if ( no == 1 ) : NEW_LINE INDENT break ; NEW_LINE DEDENT DEDENT DEDENT DEDENT