mirror of
https://github.com/boostorg/pool.git
synced 2026-02-02 09:02:13 +00:00
81 lines
2.1 KiB
HTML
81 lines
2.1 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE>gcd_lcm - GCD and LCM</TITLE>
|
|
<LINK HREF="../pool.css" REL="stylesheet" TYPE="text/css">
|
|
</HEAD>
|
|
<BODY>
|
|
|
|
<IMG SRC="../../../../c++boost.gif" WIDTH=276 HEIGHT=86 ALT="C++ Boost">
|
|
|
|
<H1 ALIGN=CENTER>gcd_lcm - GCD and LCM</H1>
|
|
|
|
<P>
|
|
<H2>Introduction</H2>
|
|
|
|
<P>
|
|
detail/gcd_lcm.hpp provides two generic integer algorithms: greatest common divisor and least common multiple.
|
|
|
|
<P>
|
|
<H2>Synopsis</H2>
|
|
<PRE CLASS="code">namespace details {
|
|
namespace pool {
|
|
|
|
template <typename Integer>
|
|
Integer gcd(Integer A, Integer B);
|
|
|
|
template <typename Integer>
|
|
Integer lcm(Integer A, Integer B);
|
|
|
|
} // namespace pool
|
|
} // namespace details</PRE>
|
|
|
|
<P>
|
|
<H2>Semantics</H2>
|
|
|
|
<TABLE ALIGN=CENTER BORDER>
|
|
<CAPTION><EM>Symbol Table</EM></CAPTION>
|
|
<TR><TH>Symbol<TH>Meaning</TR>
|
|
<TR><TD CLASS="code">Integer<TD>An integral type</TR>
|
|
<TR><TD CLASS="code">A, B<TD>Values of type <SPAN CLASS="code">Integer</SPAN></TR>
|
|
</TABLE>
|
|
|
|
<TABLE ALIGN=CENTER BORDER>
|
|
<CAPTION><EM>Semantics</EM></CAPTION>
|
|
<TR><TH>Expression<TH>Result Type<TH>Precondition<TH>Notes
|
|
<TR><TD CLASS="code">gcd(A, B)<TD>Integer<TD CLASS="code">A > 0 && B > 0<TD>Returns the greatest common divisor of <SPAN CLASS="code">A</SPAN> and <SPAN CLASS="code">B</SPAN>
|
|
<TR><TD CLASS="code">lcm(A, B)<TD>Integer<TD CLASS="code">A > 0 && B > 0<TD>Returns the least common multiple of <SPAN CLASS="code">A</SPAN> and <SPAN CLASS="code">B</SPAN>
|
|
</TABLE>
|
|
|
|
<P>
|
|
<H2>Implementation Notes</H2>
|
|
|
|
<P>
|
|
For faster results, ensure <SPAN CLASS="code">A > B</SPAN>
|
|
|
|
<P>
|
|
<H2>Dependencies</H2>
|
|
|
|
<P>
|
|
None.
|
|
|
|
<P>
|
|
<H2>Future Directions</H2>
|
|
|
|
<P>
|
|
This header may be replaced by a Boost algorithms library.
|
|
|
|
<P>
|
|
<HR>
|
|
|
|
<P>
|
|
Copyright © 2000, 2001 Stephen Cleary (scleary AT jerviswebb DOT com)
|
|
|
|
<P>
|
|
This file can be redistributed and/or modified under the terms found in <A HREF="../copyright.html">copyright.html</A>
|
|
|
|
<P>
|
|
This software and its documentation is provided "as is" without express or implied warranty, and with no claim as to its suitability for any purpose.
|
|
|
|
</BODY>
|
|
</HTML> |