Logic circuit equivalent of modulo function with fixed-size inputs and output?
If that must be hardware, separate IC is acceptable and the parallel wiring, too, then consider to program a rom. 

A gate version can be synthesized from the content of the rom by proper software. Manual synthesis is practical only for small bit counts, say 5 or less.

Surely this is implemented. It"s needed in data communication coding. Today we have incredibly effective processors available for software solutions, but at the highest speeds the coding hardware still has a place.