added fermat pseudocode, not sure if we need though