JennyCocoX
09-27-2013, 01:01 PM
Calculates the HCF for Runescape botting.
program FindingHCF;
const
Debug = True;
x = 623412;
y = 423348;
//calculates HCF of two integers x,y
Function HCF(x,y: int64):Integer;
var
i: Integer;
begin
repeat
begin
Inc(i);
If (x >= y) then
begin
If debug then
begin
Writeln('x = ' + IntToStr(x));
Writeln('y = ' + IntToStr(y));
Writeln('x mod y = ' + IntToStr(x mod y));
If i = 1 then
begin
Writeln('Completed ' + IntToStr(i) + ' calculation step.');
end
else
Writeln('Completed ' + IntToStr(i) + ' calculation steps.');
end;
x := (x mod y);
end
else
begin
if debug then
begin
Writeln('x = ' + IntToStr(x));
Writeln('y = ' + IntToStr(y));
Writeln('y mod x = ' + IntToStr(y mod x));
If i = 1 then
begin
Writeln('Completed ' + IntToStr(i) + ' calculation step.');
end
else
Writeln('Completed ' + IntToStr(i) + ' calculation steps.');
end;
y := (y mod x);
end;
end;
until (y=0) or (x=0);
If x>y then
Result := x;
If y>x then
Result := y;
end;
begin
Writeln('The HCF is ' + IntToStr(HCF(x,y)) +'.');
end.
:(
Compiled successfully in 16 ms.
x = 623412
y = 423348
The HCF is 12.
Successfully executed.
With debugging
Compiled successfully in 16 ms.
x = 623412
y = 423348
x mod y = 200064
Completed 1 calculation step.
x = 200064
y = 423348
y mod x = 23220
Completed 2 calculation steps.
x = 200064
y = 23220
x mod y = 14304
Completed 3 calculation steps.
x = 14304
y = 23220
y mod x = 8916
Completed 4 calculation steps.
x = 14304
y = 8916
x mod y = 5388
Completed 5 calculation steps.
x = 5388
y = 8916
y mod x = 3528
Completed 6 calculation steps.
x = 5388
y = 3528
x mod y = 1860
Completed 7 calculation steps.
x = 1860
y = 3528
y mod x = 1668
Completed 8 calculation steps.
x = 1860
y = 1668
x mod y = 192
Completed 9 calculation steps.
x = 192
y = 1668
y mod x = 132
Completed 10 calculation steps.
x = 192
y = 132
x mod y = 60
Completed 11 calculation steps.
x = 60
y = 132
y mod x = 12
Completed 12 calculation steps.
x = 60
y = 12
x mod y = 0
Completed 13 calculation steps.
The HCF is 12.
Successfully executed.
Still only 100% real work with smallers number because int64 is a disabled person.
program FindingHCF;
const
Debug = True;
x = 623412;
y = 423348;
//calculates HCF of two integers x,y
Function HCF(x,y: int64):Integer;
var
i: Integer;
begin
repeat
begin
Inc(i);
If (x >= y) then
begin
If debug then
begin
Writeln('x = ' + IntToStr(x));
Writeln('y = ' + IntToStr(y));
Writeln('x mod y = ' + IntToStr(x mod y));
If i = 1 then
begin
Writeln('Completed ' + IntToStr(i) + ' calculation step.');
end
else
Writeln('Completed ' + IntToStr(i) + ' calculation steps.');
end;
x := (x mod y);
end
else
begin
if debug then
begin
Writeln('x = ' + IntToStr(x));
Writeln('y = ' + IntToStr(y));
Writeln('y mod x = ' + IntToStr(y mod x));
If i = 1 then
begin
Writeln('Completed ' + IntToStr(i) + ' calculation step.');
end
else
Writeln('Completed ' + IntToStr(i) + ' calculation steps.');
end;
y := (y mod x);
end;
end;
until (y=0) or (x=0);
If x>y then
Result := x;
If y>x then
Result := y;
end;
begin
Writeln('The HCF is ' + IntToStr(HCF(x,y)) +'.');
end.
:(
Compiled successfully in 16 ms.
x = 623412
y = 423348
The HCF is 12.
Successfully executed.
With debugging
Compiled successfully in 16 ms.
x = 623412
y = 423348
x mod y = 200064
Completed 1 calculation step.
x = 200064
y = 423348
y mod x = 23220
Completed 2 calculation steps.
x = 200064
y = 23220
x mod y = 14304
Completed 3 calculation steps.
x = 14304
y = 23220
y mod x = 8916
Completed 4 calculation steps.
x = 14304
y = 8916
x mod y = 5388
Completed 5 calculation steps.
x = 5388
y = 8916
y mod x = 3528
Completed 6 calculation steps.
x = 5388
y = 3528
x mod y = 1860
Completed 7 calculation steps.
x = 1860
y = 3528
y mod x = 1668
Completed 8 calculation steps.
x = 1860
y = 1668
x mod y = 192
Completed 9 calculation steps.
x = 192
y = 1668
y mod x = 132
Completed 10 calculation steps.
x = 192
y = 132
x mod y = 60
Completed 11 calculation steps.
x = 60
y = 132
y mod x = 12
Completed 12 calculation steps.
x = 60
y = 12
x mod y = 0
Completed 13 calculation steps.
The HCF is 12.
Successfully executed.
Still only 100% real work with smallers number because int64 is a disabled person.