Calculate operations required for the current common ratio
i = 0 NEW_LINE while i < n : NEW_LINE INDENT curr_cost += abs ( arr [ i ] - prod ) NEW_LINE prod *= j NEW_LINE if ( curr_cost >= min_cost ) : NEW_LINE INDENT break NEW_LINE DEDENT i += 1 NEW_LINE DEDENT