HammingNumber trait refactored