This task requires the finding of the greatest common divisor of two integers.

Copied from least common multiple page for the sake of completeness.

#include <boost/math/common_factor.hpp>
#include <iostream>
int main( ) {
std::cout << "The least common multiple of 12 and 18 is " <<
boost::math::lcm( 12 , 18 ) << " ,\n"
<< "and the greatest common divisor " << boost::math::gcd( 12 , 18 ) << " !" << std::endl ;
return 0 ;
}

The least common multiple of 12 and 18 is 36 ,
and the greatest common divisor 6 !

SOURCE

Content is available under GNU Free Documentation License 1.2.

*Related Posts*