udfIsNumberPrime
udfGetPrimeThisOrNext
bln udfIsNumberPrime (int)
int udfGetPrimeThisOrNext (int)
;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfIsNumberPrime (intNumber)
blnIsPrime = @TRUE
intLimit = Int (Sqrt (intNumber))
For intI = 2 To intLimit
   blnIsPrime = intNumber mod intI
   If !blnIsPrime Then Break
Next
Return blnIsPrime
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------


;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfGetPrimeThisOrNext (intNumber)
While !udfIsNumberPrime (intNumber)
   intNumber = intNumber + 1
EndWhile
Return intNumber
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------


; Test.

blnResult = udfIsNumberPrime (221) ; @FALSE

intNumberPrime1 = udfGetPrimeThisOrNext (221) ; 223.

intNumberPrime2 = udfGetPrimeThisOrNext (223) ; 223.

intNumberPrime3 = udfGetPrimeThisOrNext (223 + 1) ; 227.

:CANCEL
Exit