Implement gcd, lcm (#40651)
Summary:
Resolves https://github.com/pytorch/pytorch/issues/40018.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/40651
Reviewed By: ezyang
Differential Revision: D22511828
Pulled By: mruberry
fbshipit-source-id: 3ef251e45da4688b1b64c79f530fb6642feb63ab