Skip to main content
1 of 3
Conor O'Brien
  • 40.2k
  • 3
  • 91
  • 180

Simplex v.0.5, 12 bytes

(The Docs page may be outdated; mainly, the * also increments the pointer.)

h*M{*LTRpM}]

This defines a macro that performs the factorial function on the current byte. It maintains the structure of the strip.

Here is the pseudo-code I used:

Function factorial(N)
    A = N - 1
    While A > 1
        N = A * N
        A = A - 1
    End While
    Return N
End Function

This is the expanded explanation.

h
 *   ~~ A=N [N,A]
 M   ~~ A=N-1 [N,A-1]
 {
  *  ~~ [N,A-1,A-1]
  LT ~~ [N*(A-1),0,A-1]
  Rp ~~ [N*(A-1),A-1]
  M  ~~ [N*(A-1),A-2]
 }
 p   ~~ [N!]
]
Conor O'Brien
  • 40.2k
  • 3
  • 91
  • 180