Talk:Greatest common divisor: Difference between revisions

m
→‎REXX Version 1: added whitespace.
(don't oversimplify)
m (→‎REXX Version 1: added whitespace.)
 
(4 intermediate revisions by 3 users not shown)
Line 16:
::::: The problem with dividing a number which is not zero, by zero is that you get a zero result when you multiply zero by any number. So, obviously, the issue of dividing zero by zero is different -- here, the problem is not that there's no valid answer. When you divide zero by zero, the problem is that all answers are valid. So, 0 as the answer for 0 == GCD(0,0) has to be valid. It's not the only valid answer, but it's algorithmically simple (we do not need any exceptions in the euclidean algorithm to deal with this case) and it's syntactically simple (it lets GCD be associative).
 
::::: And, this definition corresponds to the definition that Claude Shannon used for for his subset of George Boole's algebra. There are other ways of using algebraic notation with logical values, but I am reminded of this approach every typetime I use a "boolean value". --[[User:Rdm|Rdm]] 13:12, 18 August 2012 (UTC)
 
-----
 
The special case of   '''gcd(0,0)'''   is usually defined to be   '''0''',   but some authors consider it to be '''undefined'''.   When implementing the REXX version 1 example,   the first definition (equal to zero) was chosen.   So, for that case,   '''|0|│0│ = 0'''.
 
From the Wikipedia page: http://en.wikipedia.org/wiki/Greatest_common_divisor
 
It is useful to define   '''gcd(0,0) = 0'''   and   '''lcm(0,0) = 0'''   because then the natural numbers become a complete distributive lattice with   '''gcd'''   as the   ''meet''   operation,   and   '''lcm'''   as the   ''join''   operation.
 
-- [[User:Gerard Schildberger|Gerard Schildberger]] 16:10, 17 August 2012 (UTC)
Line 42:
Cases of zero have been corrected (the GCD subroutine was exiting instead of processing more arguments). The special case of gcd(0,0) can be defined to be 0, or ''undefined''. Zero was choosen. -- [[User:Gerard Schildberger|Gerard Schildberger]] 17:08, 17 August 2012 (UTC)
 
: And, yes, wikipediaWikipedia [[wp:Greatest_common_divisor#Properties|claims]] that gcd is associative. --[[User:Rdm|Rdm]] 17:31, 17 August 2012 (UTC)
 
 
::I don't understand why this is relevant! It's allso communicative.
::I'll surrender and change indef(inite) to 0 as much as I dislike to read DIVISOR=0 --[[User:Walterpachl|Walterpachl]] 15:17, 18 August 2012 (UTC)
 
== PL/I ==
 
should return a positive integer
:and take care of gcd/0,0)
--[[User:Walterpachl|Walterpachl]] 12:39, 17 August 2012 (UTC)