Given data:
The number of cups of ice cream a person eats, N=2.
Total number of people attending the party, M=24.
So, the total number of cups of ice cream needed is,

We know,

Therefore,

Therefore, the number of gallon tubs of ice cream to be bought is,

Hence, 3 gallon tubs of ice cream is to be bought by Trent.