Greatest common divisor: Difference between revisions
Content added Content deleted
(indentation) |
|||
Line 2,581: | Line 2,581: | ||
=={{header|TI-83 BASIC}}, {{header|TI-89 BASIC}}== |
=={{header|TI-83 BASIC}}, {{header|TI-89 BASIC}}== |
||
gcd(A,B) |
gcd(A,B) |
||
=={{header|TSE SAL}}== |
|||
<lang TSE SAL> |
|||
// library: math: get: greatest: common: divisor <description>greatest common divisor whole numbers. Euclid's algorithm. Recursive version</description> <version control></version control> <version>1.0.0.0.3</version> <version control></version control> (filenamemacro=getmacdi.s) [<Program>] [<Research>] [kn, ri, su, 20-01-2013 14:22:41] |
|||
INTEGER PROC FNMathGetGreatestCommonDivisorI( INTEGER x1I, INTEGER x2I ) |
|||
// |
|||
IF ( x2I == 0 ) |
|||
// |
|||
RETURN( x1I ) |
|||
// |
|||
ENDIF |
|||
// |
|||
RETURN( FNMathGetGreatestCommonDivisorI( x2I, x1I MOD x2I ) ) |
|||
// |
|||
END |
|||
PROC Main() |
|||
STRING s1[255] = "353" |
|||
STRING s2[255] = "46" |
|||
REPEAT |
|||
IF ( NOT ( Ask( " = ", s1, _EDIT_HISTORY_ ) ) AND ( Length( s1 ) > 0 ) ) RETURN() ENDIF |
|||
IF ( NOT ( Ask( " = ", s2, _EDIT_HISTORY_ ) ) AND ( Length( s2 ) > 0 ) ) RETURN() ENDIF |
|||
Warn( FNMathGetGreatestCommonDivisorI( Val( s1 ), Val( s2 ) ) ) // gives e.g. 1 |
|||
UNTIL FALSE |
|||
END |
|||
</lang> |
|||
=={{header|TXR}}== |
=={{header|TXR}}== |
||
Line 2,587: | Line 2,616: | ||
<pre>g="562949953421312"</pre> |
<pre>g="562949953421312"</pre> |
||
=={{header|UNIX Shell}}== |
=={{header|UNIX Shell}}== |