Clearly, since the two numbers are consecutive, one of them is even and the other is odd. Let's say the two numbers were 5 and 6. This would mean the secret number was not divisible by 5 nor by 6. It would also mean the number could NOT be divisible by 10, 15, 20, 25 or by 12, 18, 24 or 30. Thus the students who said it was divisible by 10, by 15, etc. would also have spoken wrong. So, the two numbers cannot be 5 and 6.
Similarly, the two numbers cannot be, say, 8 and 9, because then also the students who said it was divisible by 16, 24, 18, and 27 would have been in the wrong.
So we can conclude that these two consecutive numbers cannot have multiples that are less than 31. This eliminates a lot of numbers: 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, and 15.
Could it be, say 20 and 21? That will not work, because if this secret number IS divisible by 2 and 10, then it is also divisible by 20. Similarly, since we know the number IS divisible by all the whole numbers from 2 through 15, it must also be divisible by 18, 20, 21, 22, 24, 26, 28, and 30.
This leaves the following number pair: 16 & 17.
Or, you can think of it this way. All prime numbers, except 2, are odd. So, one number should be an odd prime and the other should be the highest power of 2 in the range.
Thus the required two numbers are 24 = 16 and 17, and the two students who spoke wrongly are 15th and 16th