5 gallons is fine for 1 cherry barb. If you have more than one, you will either have all males, who will want at least 1 square foot of footprint with a landmark as their territory (at least - my two have each claimed an end of a 75 and they defend their end from the other), all females, in which case they will establish a pecking order (though a pretty low key one) or a mix. You should have no more than one male per female, and multiple females per male is better. In the case of one male an 3 females, I would give them at least a 20 long, a 30 would be better. There can be other fish in there with them, no sweat, but that's how much room they'll need to act more or less naturally. That said, Cherry barbs are not a schooling species. They will do just fine in a 30 gallon tank with a male and a couple of females or in a 55 with a pair of males and 5 or so females. If you give them some feathery plants over java moss or coarse gravel, you may even get fry.
Logic is only the beginning of wisdom