Sign in Join
Wiki copytemporary

Greatest common divisor/fr: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
1-Le plus grand diviseur commun (PGDC) de deux entiers est le plus grand entier qui les divise les deux. Si les nombres sont 121 et 143 alors le PGDC est 11 (121=11x11 et 143=11*13)
1+Le plus grand diviseur commun (PGDC) de deux entiers est le plus grand entier qui les divise les deux. Si les nombres sont 121 et 143 alors le PGDC est 11 (121=11x11 et 143=11*13)
22
3-Il existe plusieurs méthodes pour le calculer. P.ex., l'algorithme d'Euclide basé sur la division peut être implémenté.
3+Il existe plusieurs méthodes pour le calculer. P.ex., l'algorithme d'Euclide basé sur la division peut être implémenté.
44
55## Fonction GreatestCommonDivisor
6-
7-``` pascal
8-
6+```
97function GreatestCommonDivisor(a, b: Int64): Int64;
10-var
11- temp: Int64;
12-begin
13- while b <> 0 do
14- begin
15- temp := b;
16- b := a mod b;
17- a := temp
18- end;
19- result := a
20-end;
21-
22-function GreatestCommonDivisor_EuclidsSubtractionMethod(a, b: Int64): Int64;
23-//only works with positive integers
24-begin
25- if (a < 0) then a := -a;
26- if (b < 0) then b := -b;
27- if (a = 0) then Exit(b);
28- if (b = 0) then Exit(a);
29- while not (a = b) do
30- begin
31- if (a > b) then
32- a := a - b
33- else
34- b := b - a;
35- end;
36- Result := a;
37-end;
8+ var
9+ temp: Int64;
10+ begin
11+ while b <> 0 do
12+ begin
13+ temp := b;
14+ b := a mod b;
15+ a := temp
16+ end;
17+ result := a
18+ end;
19+
20+ function GreatestCommonDivisor_EuclidsSubtractionMethod(a, b: Int64): Int64;
21+ //only works with positive integers
22+ begin
23+ if (a < 0) then a := -a;
24+ if (b < 0) then b := -b;
25+ if (a = 0) then Exit(b);
26+ if (b = 0) then Exit(a);
27+ while not (a = b) do
28+ begin
29+ if (a > b) then
30+ a := a - b
31+ else
32+ b := b - a;
33+ end;
34+ Result := a;
35+ end;
3836```
3937
4038## Voir aussi
4139
42-- [Recursive example](http://rosettacode.org/wiki/Greatest_common_divisor#Pascal_.2F_Delphi_.2F_Free_Pascal)
43-- [[Least common multiple/fr|plus petit multiple commun]]
44-- [[Mod/fr|Mod]]
40+ * [Recursive example](<http://rosettacode.org/wiki/Greatest_common_divisor#Pascal_.2F_Delphi_.2F_Free_Pascal>)
41+ * [[Least common multiple/fr|plus petit multiple commun]]
42+ * [[Mod/fr|Mod]]
4543
4644---
47-*From the Free Pascal wiki, page "Greatest common divisor/fr", as it stood on 2020-02-16 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
45+*From the Free Pascal wiki, page "Greatest common divisor/fr", as the Internet Archive kept it on 2023-03-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history