Program Bench2NaPP;
Var
B: integer;
Type
Err=0..65535;
function FlpFToA(a:real;var s:string):Err;
inline($e519c008,$e1a0e00f,$e59cf3d4);
procedure SysTaskDelay(delay:integer);
inline($E519C008,$E1A0E00F,$E59CF8E8);
function SysTicksPerSecond:integer;
inline($E519C008,$E1A0E00F,$E59CF8F4);
function TimGetTicks:integer;
inline($E519C008,$E1A0E00F,$E59CF928);
procedure WinDrawChars(const chars:string;len,x,y:integer);
inline($E519C008,$E1A0E00F,$E59CFB18);
Procedure PrintText(const s:string;x,y:integer);
begin
WinDrawChars(s,Length(s),x,y);
end;
Procedure PrintReal(r:real;x,y:integer);
var
s:string;
begin
FlpFToA(r,s);
PrintText(s,x,y);
end;
procedure PerfectNum;
{ Perfect Numbers finder routine }
var
N,D,M,S,P,T: integer;
R: real;
begin
T:=TimGetTicks;
P:=0;
for N:=2 to B*500 do begin
M:=N div 2;
S:=1;
for D:=2 to M do begin
if B=1 then if (N/D)=(N div D) then S:=S+D;
if B=2 then if (N mod D)=0 then S:=S+D;
end;
if S=N then P:=P+1;
end;
R:=(TimGetTicks-T)/SysTicksPerSecond;
if P<>3 then R:=0;
// writeln(R:1:2,' Secs');
PrintReal(R,10,B*10);
PrintText('Secs',75,B*10);
end;
begin
for B:=1 to 2 do
PerfectNum;
SysTaskDelay(5*SysTicksPerSecond);
end.
|