Skip to main content
added 105 characters in body
Source Link
Bubbler
  • 78.4k
  • 5
  • 149
  • 469

Knight, 25 bytes

;=x+=y 1P;W=x-x 1=y*x yOy

Try it online!

Ungolfed:

; = x +             x = sum of:
      = y 1           y = 1 (passes through 1) and
      PROMPT          a line from stdin (coerced to number)
; WHILE = x - x 1   while (x = x - 1) is nonzero:
  = y * x y           y = x * y
OUTPUT y            print y

In Knight, coercion depends on the type of the first argument. So 1+"5" is 6 while "5"+1 is "51".

Knight, 25 bytes

;=x+=y 1P;W=x-x 1=y*x yOy

Try it online!

Ungolfed:

; = x +             x = sum of:
      = y 1           y = 1 (passes through 1) and
      PROMPT          a line from stdin (coerced to number)
; WHILE = x - x 1   while (x = x - 1) is nonzero:
  = y * x y           y = x * y
OUTPUT y            print y

Knight, 25 bytes

;=x+=y 1P;W=x-x 1=y*x yOy

Try it online!

Ungolfed:

; = x +             x = sum of:
      = y 1           y = 1 (passes through 1) and
      PROMPT          a line from stdin (coerced to number)
; WHILE = x - x 1   while (x = x - 1) is nonzero:
  = y * x y           y = x * y
OUTPUT y            print y

In Knight, coercion depends on the type of the first argument. So 1+"5" is 6 while "5"+1 is "51".

Source Link
Bubbler
  • 78.4k
  • 5
  • 149
  • 469

Knight, 25 bytes

;=x+=y 1P;W=x-x 1=y*x yOy

Try it online!

Ungolfed:

; = x +             x = sum of:
      = y 1           y = 1 (passes through 1) and
      PROMPT          a line from stdin (coerced to number)
; WHILE = x - x 1   while (x = x - 1) is nonzero:
  = y * x y           y = x * y
OUTPUT y            print y