Skip to main content
1 of 2
chunes
  • 27.8k
  • 3
  • 32
  • 55

Factor + math.unicode, 35 bytes

[ [1,b] swap '[ _ ^ -1 ^ ] map Σ ] 

Try it online!

Explanation:

It's a quotation (anonymous function) that takes two integers from the data stack (in m, n order) as input and leaves a fully-reduced mixed fraction (it's simply the way that Factor is) on the data stack as output.

  • [1,b] swap Make a range from 1 to n and bring m to the top of the stack.
  • '[ _ ^ -1 ^ ] Push a quotation to the stack for map to use later. '[ _ says to slot whatever is on top of the data stack (m) into the _.
  • map Apply a quotation to each element of a sequence, mapping the results into a sequence of the same size.
  • ^ Raise a sequence element to the m power.
  • -1 ^ Take the reciprocal. This is shorter than recip and 1 swap /.
  • Σ Sum.
chunes
  • 27.8k
  • 3
  • 32
  • 55