Factors of 18
If he has 1 friend, he gives 18 cookies
2 friends, 9 each
3 friends, 6 each
6 friends, 3 each
9 friends, 2 each
18 friends, 1 each
these are the common factors of 18. I don't know whether fractions are applicable here but I hope this helps.