rem is more efficient than mod.
calculate the total without a list.