1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
---|
2 | <HTML> |
---|
3 | <HEAD> |
---|
4 | <TITLE>gcd_lcm - GCD and LCM</TITLE> |
---|
5 | <LINK HREF="../pool.css" REL="stylesheet" TYPE="text/css"> |
---|
6 | </HEAD> |
---|
7 | <BODY> |
---|
8 | |
---|
9 | <IMG SRC="../../../../boost.png" WIDTH=276 HEIGHT=86 ALT="C++ Boost"> |
---|
10 | |
---|
11 | <H1 ALIGN=CENTER>gcd_lcm - GCD and LCM</H1> |
---|
12 | |
---|
13 | <P> |
---|
14 | <H2>Introduction</H2> |
---|
15 | |
---|
16 | <P> |
---|
17 | detail/gcd_lcm.hpp provides two generic integer algorithms: greatest common divisor and least common multiple. |
---|
18 | |
---|
19 | <P> |
---|
20 | <H2>Synopsis</H2> |
---|
21 | <PRE CLASS="code">namespace details { |
---|
22 | namespace pool { |
---|
23 | |
---|
24 | template <typename Integer> |
---|
25 | Integer gcd(Integer A, Integer B); |
---|
26 | |
---|
27 | template <typename Integer> |
---|
28 | Integer lcm(Integer A, Integer B); |
---|
29 | |
---|
30 | } // namespace pool |
---|
31 | } // namespace details</PRE> |
---|
32 | |
---|
33 | <P> |
---|
34 | <H2>Semantics</H2> |
---|
35 | |
---|
36 | <TABLE ALIGN=CENTER BORDER> |
---|
37 | <CAPTION><EM>Symbol Table</EM></CAPTION> |
---|
38 | <TR><TH>Symbol<TH>Meaning</TR> |
---|
39 | <TR><TD CLASS="code">Integer<TD>An integral type</TR> |
---|
40 | <TR><TD CLASS="code">A, B<TD>Values of type <SPAN CLASS="code">Integer</SPAN></TR> |
---|
41 | </TABLE> |
---|
42 | |
---|
43 | <TABLE ALIGN=CENTER BORDER> |
---|
44 | <CAPTION><EM>Semantics</EM></CAPTION> |
---|
45 | <TR><TH>Expression<TH>Result Type<TH>Precondition<TH>Notes |
---|
46 | <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> |
---|
47 | <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> |
---|
48 | </TABLE> |
---|
49 | |
---|
50 | <P> |
---|
51 | <H2>Implementation Notes</H2> |
---|
52 | |
---|
53 | <P> |
---|
54 | For faster results, ensure <SPAN CLASS="code">A > B</SPAN> |
---|
55 | |
---|
56 | <P> |
---|
57 | <H2>Dependencies</H2> |
---|
58 | |
---|
59 | <P> |
---|
60 | None. |
---|
61 | |
---|
62 | <P> |
---|
63 | <H2>Future Directions</H2> |
---|
64 | |
---|
65 | <P> |
---|
66 | This header may be replaced by a Boost algorithms library. |
---|
67 | |
---|
68 | <P> |
---|
69 | <HR> |
---|
70 | |
---|
71 | <P> |
---|
72 | Copyright © 2000, 2001 Stephen Cleary (scleary AT jerviswebb DOT com) |
---|
73 | |
---|
74 | <P> |
---|
75 | This file can be redistributed and/or modified under the terms found in <A HREF="../copyright.html">copyright.html</A> |
---|
76 | |
---|
77 | <P> |
---|
78 | 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. |
---|
79 | |
---|
80 | </BODY> |
---|
81 | </HTML> |
---|