i had to get the factorial of a number but could not find a buildin function in b4x so i created a function for that.
use:
B4X:
Sub factorial(number As Int) As Int
Dim returnNr As Int = number
Do Until number <= 1
number = number - 1
returnNr = returnNr * number
Loop
Return returnNr
End Sub
use:
B4X:
Log(factorial(6))
log: 720
Last edited: