1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
---|
2 | "http://www.w3.org/TR/html4/loose.dtd"> |
---|
3 | |
---|
4 | <html> |
---|
5 | <head> |
---|
6 | <meta http-equiv="Content-Language" content="en-us"> |
---|
7 | <meta http-equiv="Content-Type" content="text/html; charset=us-ascii"> |
---|
8 | <link href="../pool.css" rel="stylesheet" type="text/css"> |
---|
9 | |
---|
10 | <title>gcd_lcm - GCD and LCM</title> |
---|
11 | </head> |
---|
12 | |
---|
13 | <body> |
---|
14 | <img src="../../../../boost.png" width="276" height="86" alt="C++ Boost"> |
---|
15 | |
---|
16 | <h1 align="center">gcd_lcm - GCD and LCM</h1> |
---|
17 | |
---|
18 | <h2>Introduction</h2> |
---|
19 | |
---|
20 | <p>detail/gcd_lcm.hpp provides two generic integer algorithms: greatest |
---|
21 | common divisor and least common multiple.</p> |
---|
22 | |
---|
23 | <h2>Synopsis</h2> |
---|
24 | <pre class="code"> |
---|
25 | namespace details { |
---|
26 | namespace pool { |
---|
27 | |
---|
28 | template <typename Integer> |
---|
29 | Integer gcd(Integer A, Integer B); |
---|
30 | |
---|
31 | template <typename Integer> |
---|
32 | Integer lcm(Integer A, Integer B); |
---|
33 | |
---|
34 | } // namespace pool |
---|
35 | } // namespace details |
---|
36 | </pre> |
---|
37 | |
---|
38 | <h2>Semantics</h2> |
---|
39 | |
---|
40 | <table align="center" border summary=""> |
---|
41 | <caption> |
---|
42 | <em>Symbol Table</em> |
---|
43 | </caption> |
---|
44 | |
---|
45 | <tr> |
---|
46 | <th>Symbol</th> |
---|
47 | |
---|
48 | <th>Meaning</th> |
---|
49 | </tr> |
---|
50 | |
---|
51 | <tr> |
---|
52 | <td class="code">Integer</td> |
---|
53 | |
---|
54 | <td>An integral type</td> |
---|
55 | </tr> |
---|
56 | |
---|
57 | <tr> |
---|
58 | <td class="code">A, B</td> |
---|
59 | |
---|
60 | <td>Values of type <span class="code">Integer</span></td> |
---|
61 | </tr> |
---|
62 | </table><br> |
---|
63 | |
---|
64 | <table align="center" border summary=""> |
---|
65 | <caption> |
---|
66 | <em>Semantics</em> |
---|
67 | </caption> |
---|
68 | |
---|
69 | <tr> |
---|
70 | <th>Expression</th> |
---|
71 | |
---|
72 | <th>Result Type</th> |
---|
73 | |
---|
74 | <th>Precondition</th> |
---|
75 | |
---|
76 | <th>Notes</th> |
---|
77 | </tr> |
---|
78 | |
---|
79 | <tr> |
---|
80 | <td class="code">gcd(A, B)</td> |
---|
81 | |
---|
82 | <td>Integer</td> |
---|
83 | |
---|
84 | <td class="code">A > 0 && B > 0</td> |
---|
85 | |
---|
86 | <td>Returns the greatest common divisor of <span class="code">A</span> |
---|
87 | and <span class="code">B</span></td> |
---|
88 | </tr> |
---|
89 | |
---|
90 | <tr> |
---|
91 | <td class="code">lcm(A, B)</td> |
---|
92 | |
---|
93 | <td>Integer</td> |
---|
94 | |
---|
95 | <td class="code">A > 0 && B > 0</td> |
---|
96 | |
---|
97 | <td>Returns the least common multiple of <span class="code">A</span> |
---|
98 | and <span class="code">B</span></td> |
---|
99 | </tr> |
---|
100 | </table> |
---|
101 | |
---|
102 | <h2>Implementation Notes</h2> |
---|
103 | |
---|
104 | <p>For faster results, ensure <span class="code">A > B</span></p> |
---|
105 | |
---|
106 | <h2>Dependencies</h2> |
---|
107 | |
---|
108 | <p>None.</p> |
---|
109 | |
---|
110 | <h2>Future Directions</h2> |
---|
111 | |
---|
112 | <p>This header may be replaced by a Boost algorithms library.</p> |
---|
113 | <hr> |
---|
114 | |
---|
115 | <p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src= |
---|
116 | "http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" |
---|
117 | height="31" width="88"></a></p> |
---|
118 | |
---|
119 | <p>Revised |
---|
120 | <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->05 |
---|
121 | December, 2006<!--webbot bot="Timestamp" endspan i-checksum="38516" --></p> |
---|
122 | |
---|
123 | <p><i>Copyright © 2000, 2001 Stephen Cleary (scleary AT jerviswebb DOT |
---|
124 | com)</i></p> |
---|
125 | |
---|
126 | <p><i>Distributed under the Boost Software License, Version 1.0. (See |
---|
127 | accompanying file <a href="../../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> |
---|
128 | or copy at <a href= |
---|
129 | "http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>)</i></p> |
---|
130 | </body> |
---|
131 | </html> |
---|