ntheory: move implementation of fns to .cpp file

This way the header file is small and compiles faster. Only if it turns out
that using "inline" is faster for some particular algorithm, should we use
inline functions.