Ask HN: algorithm to slice a number into parts

https://news.ycombinator.com/item?id=443072
by adm • 18 years ago
6 14 18 years ago

I am trying to write a algorithm to slice a number into parts; such that those slices add upto original number.

  e.g. n = (n1 + n2+ .. + nm)
  where n is number and m no of slices.

  n will be positive integer and m won't exceed 50.
Do you know any algorithm for this?

Edit: slices should be of distinct values.

Related Stories

Loading related stories...

Source preview

news.ycombinator.com