Blender
2009-07-15 01:45:21
Yeah, so I just took some math classes and found out that SCAR has nothing included that finds the GCM of anything.
I just mad a bunch of random (but useful) functions that have to do with math:
I just mad a bunch of random (but useful) functions that have to do with math:
{*******************************************************************************
function GCF(a, b: Integer): Integer;
By: Blender
Description: Finds the Greatest Common Factor (GCF) of a and b.
*******************************************************************************}
function GCF(a, b: Integer): Integer;
var t: Integer;
begin
while not(b = 0) do
begin
t := b;
b := a mod b;
a := t;
end;
Result := a;
end;
{*******************************************************************************
function GCD(a, b: Integer): Integer;
By: Blender
Description: Finds the Greatest Common Denominator (GCD) of a and b.
*******************************************************************************}
function GCD(a, b: Integer): Integer;
begin
Result := GCF(a, b);
end;
{*******************************************************************************
function LCM(a, b: Integer): Integer;
By: Blender
Description: Finds the Least Common Multiple (LCM) of a and b.
*******************************************************************************}
function LCM(a, b: Integer): Integer;
var c: Extended;
begin
c := abs(a) / GCD(a, b);
Result := StrToInt(FloatToStr(c * abs(b)));
end;