Różnice

Różnice między wybraną wersją a wersją aktualną.

Odnośnik do tego porównania

pl:prolog:pllib:comon_divisor [2019/06/27 15:50] (aktualna)
Linia 1: Linia 1:
 +====== Comon divisor ======
 +{{tag>​math}}
 +===== Description =====
 +Computing the greatest common divisor of two integers.
 +
 +**Source**: ​ The Art of Prolog
 +===== Download =====
 +Program source code: {{comon_divisor.pl}}
 +===== Listing =====
 +<code prolog>
 +/*
 +   ​greatest_common_divisor(X,​Y,​Z) :- 
 + Z is the greatest common divisor of the integers X and Y.
 +*/
 +     ​greatest_common_divisor(I,​0,​I).
 +     ​greatest_common_divisor(I,​J,​Gcd) :-
 +          J > 0, R is I mod J, greatest_common_divisor(J,​R,​Gcd).
 +
 +%  Program 8.1    Computing the greatest common divisor of two integers
 +</​code>​
 +===== Comments =====
  
pl/prolog/pllib/comon_divisor.txt · ostatnio zmienione: 2019/06/27 15:50 (edycja zewnętrzna)
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0