Refactor `ntheory.h`