Skip to content

Instantly share code, notes, and snippets.

@trashvin
Created November 16, 2021 17:17
Show Gist options
  • Save trashvin/daf5725097da672663dc2598cdb4e63e to your computer and use it in GitHub Desktop.
Save trashvin/daf5725097da672663dc2598cdb4e63e to your computer and use it in GitHub Desktop.
The "code" from Power Automate Desktop to demonstrate recursion when solving the factorial of a number. NOTE: you need to recreate the flow by pasting the code below in PAD. #DesktopFlowAsCode
# if you're reading this code, create a subflow named "compute_factorial" in PAd and paste this code.
SET result TO number
LABEL REPEAT_STEP
IF number = 1 THEN
EXIT FUNCTION
ELSE
SET result TO result * (number - 1)
SET number TO number - 1
GOTO REPEAT_STEP
END
# copy this codes to the Main flow in PAD. you may need to create the "theInput" input variable
Text.ToNumber Text: theNumber Number=> number
CALL compute_factorial
Display.ShowMessage Title: $'''Result''' Message: $'''Factorial = %result%''' Icon: Display.Icon.Information Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False ButtonPressed=> ButtonPressed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment