Ran into this issue in a programming challenge on HackerRank and I was surprised there weren’t any “simple” solutions online. The math related is mostly focused on finding the number of possible partitions of an integer, instead of generating even just one such partition.

A very naive approach might be to enumerate all partitions and then filter them down to those with exactly the wanted number of summands and then filter further to those with distinct parts and pick the first that fulfills the conditions.

But when the subject integer can be 1018 then that simply isn’t realistic. Insert sophisticated simile involving the heat death of the universe.