This site is supported by donations to The OEIS Foundation.
Template:GCD/doc
This template employs intricate features of template syntax.
You are encouraged to familiarize yourself with its setup and parser functions before editing the template. If your edit causes unexpected problems, please undo it quickly, as this template may appear on a large number of pages.
The {{GCD}} mathematical function template returns the greatest common divisor (GCD) of one or two integers, as a nonnegative integer, unless the templates/parser functions nesting limit (depending on the configuration settings of the MediaWiki server) is exceeded by the Euclidean algorithm, in which case an error message is returned.
are generally defined as 0. Essentially 0 acts as the top element ( or ) in this and other contexts.[1][2][3]
Currently, the OEIS Wiki server seems to be configured to limit the number of nested template transclusions to 14 (which gives a limit of 13 iterations of the Euclidean algorithm, the {{GCD}} shell function doing only data validation and preparation for the {{~GCD}} core function, which implements the 0 th iteration of the Euclidean algorithm).
Contents
Usage
- {{GCD|an integer|an integer}}
or
- {{gcd|an integer|an integer}}
or
- {{GCD|an integer}}
or
- {{gcd|an integer}}
Valid input
One or two integers as arguments.
Examples
Examples with valid input (returns GCD, unless the 10 iterations limit of the Euclidean algorithm is exceeded, where 0 is returned)
code result {{GCD|0}} 0 {{GCD|0|0}} 0 {{GCD|1}} 1 {{GCD|6}} 6 {{GCD|0|6}} 6 {{GCD|6|0}} 6 {{GCD|16|6}} 2 {{GCD|16|32}} 16 {{GCD|25|625}} 25 {{GCD|544|119}} 17 {{GCD|119|544}} 17 {{GCD|-544|119}} 17 {{GCD|544|-119}} 17 {{GCD|-544|-119}} 17 {{GCD|2089|3571}} 1 {{GCD|3571|2089}} 1 {{GCD|{{Fibonacci|12}}|{{Fibonacci|11}}}} = {{GCD|144|89}} 1 {{GCD|{{Fibonacci|13}}|{{Fibonacci|12}}}} = {{GCD|233|144}} 1 {{GCD|{{Fibonacci|14}}|{{Fibonacci|13}}}} = {{GCD|377|233}} 1 {{GCD|{{Fibonacci|15}}|{{Fibonacci|14}}}} = {{GCD|610|377}} 1 {{GCD|{{Fibonacci|16}}|{{Fibonacci|15}}}} = {{GCD|987|610}} Expression error: Unrecognized punctuation character "{". {{GCD|{{Fibonacci|17}}|{{Fibonacci|16}}}} = {{GCD|1597|987}} Expression error: Unrecognized punctuation character "{". {{GCD|{{Fibonacci|18}}|{{Fibonacci|17}}}} = {{GCD|2584|1597}} Expression error: Unrecognized punctuation character "{". {{GCD|{{Fibonacci|19}}|{{Fibonacci|18}}}} = {{GCD|4181|2584}} Expression error: Unrecognized punctuation character "{". {{GCD|{{Fibonacci|20}}|{{Fibonacci|19}}}} = {{GCD|6765|4181}} Expression error: Unrecognized punctuation character "{". {{GCD|20891|35713}} 1 {{GCD|{{expr|2*3*5*7*11*13*17*19}}|{{expr|7*17*101*113}}}} 119 {{mpf|{{GCD|{{expr|2*3*5*7*11*13*17*19}}|{{expr|7*17*101*113}}}}}} 7^1 * 17^1
Examples with invalid input (returns an error message)
code result {{GCD}} GCD error: One or two integers as arguments are required. {{GCD|ten|fifteen}} GCD error: One or two integers as arguments are required. {{GCD|6.74|9}} GCD error: One or two integers as arguments are required. {{GCD|2/3|4/9}} GCD error: One or two integers as arguments are required.
Code
Test
See also
Notes
- ↑ gcd(0,0) = 0, PlanetMath.
- ↑ Greatest common divisor, www.mathworks.com (gcd(0,0) returns 0 on Maple).
- ↑ (Maxima) question about gcd(0,0) (Maxima returns 0 for gcd(0,0))