Problem 5.7. In a class, there are 31 students. Three of them have exactly three friends each, the next three have six each, the next three have nine each, ..., and the next three have thirty each. How many friends does the 31st student have? (Friendship between people is mutual.)

![](https://cdn.mathpix.com/cropped/2024_05_06_32e5791ee8081231aabeg-6.jpg?height=494&width=525&top_left_y=80&top_left_x=464)

Fig. 2: to the solution of problem 5.6

![](https://cdn.mathpix.com/cropped/2024_05_06_32e5791ee8081231aabeg-6.jpg?height=260&width=521&top_left_y=661&top_left_x=466)

Fig. 3: to the solution of problem 5.6

#
# Answer: 15.

Solution. Let the 31st student have $x$ friends.

Consider three people, each of whom has 30 friends in the class. There are a total of 31 students in the class, so they are friends with all their classmates.

Let's expel them from the class. Then the number of friends for each person will decrease by 3:

- the first trio will have 0 friends each;
- the second trio will have 3 friends each;
- $\ldots$
- the ninth trio will have 24 friends each;
- the last student will have $x-3$ friends.

We will also expel the three students who have no friends. Then the configuration will look like this.

There are 25 students in the class. Three of them have exactly three friends each, the next three have six each, the next three have nine each, ..., the next three have 24. The last student has $x-3$ friends.

Repeat a similar action 4 more times. Then only the last student will remain in the class, and he will have $x-15$ friends. Since at this moment there are no more people left in the class, $x=15$.