Skip to main content
added 61 characters in body
Source Link
Kroppeb
  • 1.7k
  • 9
  • 11

Brachylog, 77 6 bytes

By making a range and multiplying it

-1 byte tanks to ovs having the idea to use the max() function

0∧1|⟦₁×;1⌉⟦₁×

Explanation

0 ;1          --  If n == 0:
 ∧1         --  n<1, use n=1 instead return(zero 1case)
|           --  Else:
 ⟦₁         --      Construct the range [1,n]
   × ×       --      return the product of said range

Try it online!Try it online!


Brachylog, 1110 9 bytes

recursion

0∧1|≤1|-₁↰;?×

Explanation

            --f(n):
0 ≤1          --  if n == 01:
 ∧1         --      return 1
|           --  else:
 -₁↰        --      f(n-1)
    ;?×     --            *n

Try it online!Try it online!

Brachylog, 7 bytes

By making a range and multiplying it

0∧1|⟦₁×

Explanation

0           --  If n == 0:
 ∧1         --      return 1
|           --  Else:
 ⟦₁         --      Construct the range [1,n]
   ×        --      return the product of said range

Try it online!


Brachylog, 11 bytes

recursion

0∧1|-₁↰;?×

Explanation

            --f(n):
0           --  if n == 0:
 ∧1         --      return 1
|           --  else:
 -₁↰        --      f(n-1)
    ;?×     --            *n

Try it online!

Brachylog, 7 6 bytes

By making a range and multiplying it

-1 byte tanks to ovs having the idea to use the max() function

;1⌉⟦₁×

Explanation

;1          --  If n<1, use n=1 instead (zero case)
  ⟦₁        --      Construct the range [1,n]
    ×       --      return the product of said range

Try it online!


Brachylog, 10 9 bytes

recursion

≤1|-₁↰;?×

Explanation

            --f(n):
≤1          --  if n  1: return 1
|           --  else:
 -₁↰        --      f(n-1)
    ;?×     --            *n

Try it online!

Source Link
Kroppeb
  • 1.7k
  • 9
  • 11

Brachylog, 7 bytes

By making a range and multiplying it

0∧1|⟦₁×

Explanation

0           --  If n == 0:
 ∧1         --      return 1
|           --  Else:
 ⟦₁         --      Construct the range [1,n]
   ×        --      return the product of said range

Try it online!


Brachylog, 11 bytes

recursion

0∧1|-₁↰;?×

Explanation

            --f(n):
0           --  if n == 0:
 ∧1         --      return 1
|           --  else:
 -₁↰        --      f(n-1)
    ;?×     --            *n

Try it online!