you can actually do this in 'reverse' too
fill the 3 gallon and pour it into the 5 gallon
fill the 3 gallon again and fill the 5 gallon, you now have one gallon left in the 3 gallon
empty the 5 gallon and pour the remaining 1 gallon from the 3 gallon into the 5 gallon
fill the 3 gallon again and pour it into the 5 gallon
there is now 4 gallons in the 5 gallon
though i think this way is a bit more complicated (ie more steps)
next riddle is yours