procedure TForm1.SolveBtnClick(Sender: TObject);
{SolveBtn was clicked}
var
  i,stop,n,cats,mice:integer;
begin
  stop:=trunc(sqrt(10001)); {trunc function makes it an integer}
  for i:= 3 to stop do
  begin
    {a mod b returns the remainder when a is divided by b}
    if 10001 mod i = 0 then
    begin
      n:=10001 div i; {i is one factor , get the other one}
      if n>i then begin cats:=i; mice:=n; end
      else begin cats:=n; mice:=i; end;
      showmessage('Number of cats was '+inttostr(cats)  {inttostr converts integer to string}
                  +' Number of mice caught by each cat was '
                  +inttostr(mice));
    end;
  end;
end;