Solved LeetCode program · 770 of 1,000
#1006 · Clumsy Factorial
Original English source
The count is 10. The stack is an empty list of whole numbers. Place count into stack. The spot is count minus 1. The phase is 0.
Repeat while spot is at least 1.
The size is the number of items in stack. The top is item (size minus 1) of stack. If phase is 0, set item (size minus 1) of stack to top times spot. If phase is 1, set item (size minus 1) of stack to top divided by spot. If phase is 2, Place spot into stack. If phase is 3, Place 0 minus spot into stack. Set phase to (phase plus 1) modulo 4. Decrease spot by 1.
The total is 0.
For each entry in stack.
Add entry to total.
Show total.
Expected stdout
12