Private Sub generate As String
Dim digit() As String = Array As String("2", "3", "4", "5", "6", "7", "8", "9")
Dim operator() As String = Array As String(" + ", " - ", " * ", " / ")
Dim e As B4XEval
e.Initialize(Me, "eval")
Dim equation As String
Dim check As Float
Dim result As Int
Do Until (result > 0) And (result < 100)
equation = digit(Rnd(0, 8)) & operator(Rnd(0, 3)) & digit(Rnd(0, 8)) & operator(Rnd(0, 3)) & digit(Rnd(0, 8))
If (Rnd(1, 3) = 2) Then equation = equation & operator(Rnd(2, 4)) & digit(Rnd(0, 8))
check = e.Eval(equation) ' Calculate float value
result = Round(check) ' Convert to integer value
If (Abs(result - check) > 0) Then result = 0 ' Discard if not an integer result
Loop
equation = equation.Replace("*", "x").Replace("/", "÷")
Log("Equation = " & equation & " = " & result)
Return equation
End Sub