posted 6 months ago
hi Jon,
what is the question? How much rent a group of N students must pay, given the surcharge, or the number of rooms required?
To determine the number of rooms needed, why not use the '\' operator. For instance, if 11 = 2 * 5 + 1, then 11 % 5 = 1, and 11 \ 5 = 2.
If we have 1, 2, 3 or 4 students, we need 1 room. Unfortunately, students \ 4 will yield the reaults 0, 0, 0, 1. However, studens 0, 1, 2, 3 \ 4 will give 0 in all cases. That is not 1, but it is equal for all the nr of studens.
So, what do we get when we first subtract 1 from the number of students, and THEN do the '\4' operation?
We get:
nr of st. nr of rooms (students - 1) \ 4
1, 2, 3, 4 0
5, 6, 7, 8 1
9, 10, 11, 12 2
Not quite correct, but close. Can you make it perfect?