Answer:
The least value of n is, 9.
Explanation:
Let n be the number of sheep in Integer.
Mary(M) owned the number of sheep is n i.e, M = n sheep
Sam(S) had exactly four times as many sheep as Mary , i.e, S = 4 n sheep
As per the given condition Mary buys 17 extra sheep
Now, Mary has total number of sheep, M = n +17 sheep
And Sam sells 8 of his sheep that means he has now,
But, Sam still has more sheep than Mary i.e,

Solve an inequality:

Add 8 both sides we get;

Simplify:

Now, subtract n from both the side, we get;

Simplify:
or

Since n is the number of sheep in integer,
then the least value of n is, 9.