Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- static const long GOOBS = 600851475147;
- template <long PF, long G, class Enable=void>
- struct Factor {
- static const long result = G;
- };
- // is factor
- template <long PF, long G>
- struct Factor<PF,G,std::enable_if_t<PF <= std::sqrt(G)>> {
- static const long result = (G % PF) ?
- Factor<PF+2, G>::result : // is not factor
- Factor<PF, G/PF>::result; // is factor
- };
- int main() {
- std::cout << Factor<3, GOOBS>::result << "\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement