Divide a number to unequal parts

9.5k Views Asked by At

I have an exam later today and one of the problems I'm expecting is to divide a number to multiple integers. The results must be all positive integers. But the input may not be dividable into equal parts.

If I take 660 for example, and divided it to 7 pieces, I will get 94.28 which is not an integer. Rather I want an answer something like, 94 (5x) and 95 (2x). I know I could try out a couple of numbers, but I wanted to do it way more efficiently. Thanks in advance.

2

There are 2 best solutions below

0
On

I found one way, may not be the most efficient though.

First divide the number and forget the fractions.

  • 660/7 = 94.28 (forget 0.28) it becomes 94.
  • and 94 * 7 = 658,
  • 660 - 658 = 2 (you have this much extras)
  • Now you can add 2 to one part or add them to two parts
  • i.e 5x94, 2x95 or 6x94, 1x96
3
On

The Prime Factors of 660 are $2^2 \times 3 \times 5 \times 11$ so it can not be divided to more than 5 pieces (equal or not equal).