Skip to main content
Updating to new interpreter
Source Link
d01
  • 3.4k
  • 13
  • 26

Rattle, 14 bytes

|F0:s[1F]-F0*~

Try it Online!Try it Online!

There's already a Rattle answer here by me but this approach is completely different. Not only does this answer use the shiny new interpreter, but it takes advantage of the fact that recursion was recently implemented in Rattle!

Explanation

|                parses the user's input
 F0              calls local function 0
   :             (separator between the main method and local function 0)
    s            save the current value to local memory slot 0 (local to only this instance of F0)
     [1 ]        if the value is equal to 1, then:
       F         return (returns 1)
         -       subtract 1 from the current value
          F0     recursively call function 0 with the current value as a parameter
            *~   multiply the result of function 0 by the value stored in local memory
                 (the result of the multiplication is returned)

Rattle is able to process factorials up to 170! with no loss in precision.

Rattle, 14 bytes

|F0:s[1F]-F0*~

Try it Online!

There's already a Rattle answer here by me but this approach is completely different. Not only does this answer use the shiny new interpreter, but it takes advantage of the fact that recursion was recently implemented in Rattle!

Explanation

|                parses the user's input
 F0              calls local function 0
   :             (separator between the main method and local function 0)
    s            save the current value to local memory slot 0 (local to only this instance of F0)
     [1 ]        if the value is equal to 1, then:
       F         return (returns 1)
         -       subtract 1 from the current value
          F0     recursively call function 0 with the current value as a parameter
            *~   multiply the result of function 0 by the value stored in local memory
                 (the result of the multiplication is returned)

Rattle is able to process factorials up to 170! with no loss in precision.

Rattle, 14 bytes

|F0:s[1F]-F0*~

Try it Online!

There's already a Rattle answer here by me but this approach is completely different. Not only does this answer use the shiny new interpreter, but it takes advantage of the fact that recursion was recently implemented in Rattle!

Explanation

|                parses the user's input
 F0              calls local function 0
   :             (separator between the main method and local function 0)
    s            save the current value to local memory slot 0 (local to only this instance of F0)
     [1 ]        if the value is equal to 1, then:
       F         return (returns 1)
         -       subtract 1 from the current value
          F0     recursively call function 0 with the current value as a parameter
            *~   multiply the result of function 0 by the value stored in local memory
                 (the result of the multiplication is returned)

Rattle is able to process factorials up to 170! with no loss in precision.

Source Link
d01
  • 3.4k
  • 13
  • 26

Rattle, 14 bytes

|F0:s[1F]-F0*~

Try it Online!

There's already a Rattle answer here by me but this approach is completely different. Not only does this answer use the shiny new interpreter, but it takes advantage of the fact that recursion was recently implemented in Rattle!

Explanation

|                parses the user's input
 F0              calls local function 0
   :             (separator between the main method and local function 0)
    s            save the current value to local memory slot 0 (local to only this instance of F0)
     [1 ]        if the value is equal to 1, then:
       F         return (returns 1)
         -       subtract 1 from the current value
          F0     recursively call function 0 with the current value as a parameter
            *~   multiply the result of function 0 by the value stored in local memory
                 (the result of the multiplication is returned)

Rattle is able to process factorials up to 170! with no loss in precision.