When you divide two powers of the same base, you subtract the exponents:
[tex] \dfrac{a^b}{a^c} = a^{b-c} [/tex]
This means that, in your case,
[tex] \dfrac{7^n}{7^5} = 7^p \iff 7^{n-5} = 7^p \iff n-5 = p [/tex]
So, if [tex] n=18 [/tex], the equation becomes
[tex] 18-5 = p \iff p = 13 [/tex]