Skip to main content
added 180 characters in body
Source Link
maxb
  • 7k
  • 3
  • 33
  • 41

MathGolf, 77 6 bytes

╒x%ª+ε*╙╒x%ε* 

Try it online!Try it online!

Without handlingFound a clever way to handle 0! without changing the other test cases. Takes input as \$0!\$ this would have been more impressivek n (reverse order), which helps with implicit popping.

Explanation

 maximum of rangetwo elements (1pops largest of k and n,n+1) x reversewhich array is n %for every valid case except 0!, where slice1 tois getpushed)  every k:th element  ª+ range(1,n+1)  x extend list with [1] (handles 0!)reverse int/array/string  %  slice every k:th element  ε* reduce list with multiplication 

MathGolf, 7 bytes

╒x%ª+ε* 

Try it online!

Without handling \$0!\$ this would have been more impressive.

Explanation

 range(1,n+1) x reverse array  % slice to get every k:th element  ª+ extend list with [1] (handles 0!) ε* reduce list with multiplication 

MathGolf, 7 6 bytes

╙╒x%ε* 

Try it online!

Found a clever way to handle 0! without changing the other test cases. Takes input as k n (reverse order), which helps with implicit popping.

Explanation

 maximum of two elements (pops largest of k and n, which is n for every valid case except 0!, where 1 is pushed)   range(1,n+1)  x reverse int/array/string  %  slice every k:th element  ε* reduce list with multiplication 
Source Link
maxb
  • 7k
  • 3
  • 33
  • 41

MathGolf, 7 bytes

╒x%ª+ε* 

Try it online!

Without handling \$0!\$ this would have been more impressive.

Explanation

╒ range(1,n+1) x reverse array % slice to get every k:th element ª+ extend list with [1] (handles 0!) ε* reduce list with multiplication