Hi Ravi,
Step 1: Create a Microflow
CheckPrimeNumber
).Number
of type Integer
or Long
.Step 2: Implement Prime Checking Logic
Check if the number is less than 2:
Exclusive Split
with the expression $Number < 2
.End Event
returning false
.Check if the number is 2:
Exclusive Split
with the expression $Number = 2
.End Event
returning true
.Loop through possible divisors:
Loop
with variable i
from 2 to Math.floor(Math.sqrt($Number))
.Exclusive Split
with the expression $Number mod $i = 0
.End Event
returning false
.End of Loop:
End Event
returning true
.Step 3: Use the Microflow
Call this microflow wherever you need to check if a number is prime.
This microflow will return true
if the number is prime and false
otherwise.
Hope it helps,
Rishabh
(Resilient It Services)