How many permutations of the letters (c, d, e, f, g, h, i, j) will have either 5 or 6 letters between f and g?
I assume that you mean exactly five or six letters between f & g.
There are $\mathcal{P}_5^6=720$ permutations of six taken five at a times.
Choose any one of those 'blocks' there are two ways to place f & g at each end of the block.
That accounts for seven of the letters there are then two ways to place the eighth letter.
So how many ways does that give to have exactly five letters between f & g?
The next part, six letters between is even easier.
If my basic math is correct (which it probably is not), you have 720 permutations for the options of 5 letters inside f and g. Then times it by 2 to account for f or g at the either end of these letters. Then would you times by 2 again for the eight letter that can go at either end?
720*2*2 = 2,880 ways?
Can you just clarify to me why it is 6 distinct objects and you have a sample of 5? I try to show this using 8 boxes in a line. There are two "ways" that there can be 5 letters between, where you shift the middle 5 one spot to the left or right while still leaving a square on each end of the 5 letters.
I assume again that you mean exactly 5 or 6.
${\color{red}{\boxed{f}}}{\color{blue}{\boxed{i}}} {\color{blue}{\boxed{c}}}{\color{blue}{\boxed{d}}} {\color{blue}{\boxed{e}}}{\color{blue}{\boxed{j}}} {\color{red}{\boxed{g}}}{\boxed{h}}$
Those are your boxes. The g&f are fixed and in this example h is the odd-letter out.
There are six ways to choose the odd-letter out and two places to put it (leading or tailing).
There are two ways to place each of f & g.
The blue boxes contain the other five letters and can be arranged in $5!$ ways.
That gives $(6)(2)(2)(5!)$ for exactly five letters between f & g.
For exactly six letters between f & g there is no odd-letter out.
So that gives $(2)(6!)$ for exactly six letters between f & g.