I need 30 students to form a group to find out the best group size in their project work.

the principle forming a group is the last group size lower than by one, the number of groups = the total count

for example 30 students:

7+6+5+4+3+2+1 = 28, here the total number is not equal 30 , here, we ignore 2 students since 2 students are not sufficient to form a group.

The total number of groups is 7

how we can make this in a while loop, could you share your knowledge?

the result shows like this if students = 30

print(group_total)

[1] 36

print(group_size)

[1]

print(n_groups)

[1] 7

however, the result should look like this

print(group_total)

[1] 28

print(group_size)

[1] 7

[1] 6

[1] 5

[1] 4

[1] 3

[1] 2

[1] 1

print(n_groups)

[1] 7

```
students <- as.integer(readline(prompt="Please Enter any integer number of students: "))
group_size<- 0
n_groups <-0
group_total <- 0
while (group_size <= students) {
group_total <- group_total + n_groups
n_groups <- n_groups + 1
group_size <- group_total + 1
}
print(group_total)
print(group_size)
```