Greatest common divisor: Difference between revisions

m
m (→‎{{header|Phix}}: added syntax colouring the hard way)
Line 3,265:
=={{header|Pascal}} / {{header|Delphi}} / {{header|Free Pascal}}==
===Recursive Euclid algorithm===
{{works with|Free Pascal|version 3.2.0 }}
<lang pascal>
PROGRAM EXRECURGCD.PAS;
{$mode objFPC}{R+}
 
(*
* Free Pascal Compiler version 3.2.0 [2020/06/14] for x86_64
* The free and readable alternative
* compiles natively to almost any platform, including raspberry PI *
*)
 
{$IFDEF FPC}
{$mode objfpc}{$H+}{$J-}{R+}
{$ELSE}
{$APPTYPE CONSOLE}
{$ENDIF}
 
FUNCTION gcd_recursive(u, v: longint): longint;
 
BEGIN
IF v = 0 THEN EXIT( u );
result := gcd_recursive( v, u MOD v ) ;
END;
 
BEGIN
</lang>
 
WriteLn ( gcd_recursive ( 231, 7 ) ) ;
 
END.
 
</lang>JPD 2021/03/14
 
===Iterative Euclid algorithm===
122

edits