Hi,

I have a Delphi app that shows al integers form 0-100,000 in a listbox and the numbers that are prime are shown in a second listbox. Calculation speed Delphi 1.9 sec. In Xojo I have the same app, and the calculation time is 46 secs.

Heavy lifting of the calculation is done by IsPrime function:

In Delphi/Pascal:

```
function IsPrime(X: Integer):Boolean;
begin
if (X <= 1) then Exit(False);
var Q := Floor(Sqrt(X));
for var i := 2 to Q do
if (X Mod I = 0) then
Exit(False);
Exit(True);
end;
```

In Xojo:

```
Public Function IsPrime(X as Integer) As Boolean
If (X <= 1) Then
Return False
End If
Var Q As Double = Floor(Sqrt(X))
For I As Integer = 2 To Q
If (X Mod I = 0) Then
Return False
Else
Return True
End If
Next
End Function
```

The app fills the listbox in a for/next loop and tests every integer (which is not necessary, could do with only odds). Delphi:

```
procedure TForm4.OKClick(Sender: TObject);
var
I: Integer;
SW: TStopwatch;
begin
SW := TStopwatch.StartNew;
for I := 0 to 100000 do
begin
NumListBox.Items.Add(IntToStr(i));
if IsPrime(i) then PrimeListBox.Items.Add(IntToStr(i));
end;
ShowMessage('Time: ' + FormatDateTime('hh:nn:ss:zzz',sw.ElapsedMilliseconds/MSecsPerDay));
end;
```

Xojo:

```
Dim start As Double = System.Ticks
Var TotalNumbers As Integer = 100000
For i As Integer = 0 To TotalNumbers
NumListBox.AddRow(Str(I))
If IsPrime(I) Then
PrimeListBox.AddRow(Str(I))
End If
Next
Var elapsedSeconds As Double = (Ticks - start) / 60
MessageBox("Time: " + elapsedSeconds.ToString)
```

This difference is huge. How to improve it?