We need to use some logic, here
Let n = the number of neighbors
Let q be the number of oranges that each neighbor received
Let r be the number of apples that each received.......and we have the following system:
150 = q*n + 17 → q*n = 133 (1)
100 = r*n + 5 → r*n = 95 (2)
Subtract (2) from (1)
q*n - r*n = 38 factor out n
n (q - r) = 38
Since 38 factors as 2 * 19 or 19 * 2 ........
We can assume that n = 2 or n = 19
But...if n = 2 then "q" and "r" in both (1) and (2) would be fractions
So.....let us assume that n = 19
Then q = 133/19 = 7
And r = 95/19 = 5
So....there were 19 neighbors
Another way to do this is to factor both 133 and 95
133 = q * n = 7 * 19
95 = r * n = 5 * 19 and it would be clear that n = 19 in both (1) and (2)
