Keep in mind that this will round down for the average due to integer truncating. If you want to round it up you must first convert the sum to a double (or float) and then take the math.ceil() of the resulting average