Weierstrass points and Osculating Hyperplanes Let $X$ be an irreducible non-singular curve of genus $g$, embedded in $\mathbb{P}^n$ via the canonical embedding. 
Let $j$ be an integer, and $P\in X$ a point on the curve. I would like to prove the following statement: 

The integer $j+1$ is a Weierstrass gap for $P$ if and only if there
  exists a hyperplane $H\subseteq\mathbb{P}^{n}$ such that $H$ intersects $X$
  at $P$ with multiplicity exactly $j$.

Recall that an integer $s$ is called a Weierstrass gap for a point $P\in X$ if there does not exist any meromorphic function $f$ on $X$ such that $f$ is regular outside of $P$, and has pole of order $s$ at $P$.
This should apparently follow from Riemann-Roch Theorem. Which line bundles should I apply the Riemann-Roch theorem on? This seems to be an important characterization of Weierstrass points, so it might be helpful to have a canonical answer in this website. 
 A: Let $s=j+1$.  A meromorphic function with a pole of order $s$ at $P$ which is regular at all other points is exactly a section of $\mathcal{O}_X(sP)$ which is not a section of $\mathcal{O}_X((s-1)P)$.  So $s$ is a Weierstrass gap at $P$ iff $$\ell(sP)=\ell((s-1)P).$$  By Riemann-Roch, this is equivalent to $$\ell(K-sP)=\ell(K-(s-1)P)-1$$ where $K$ is the canonical divisor.  That is, $s$ is a Weierstrass gap at $P$ iff there is a section of $\mathcal{O}_X(K-(s-1)P)$ which is not a section of $\mathcal{O}_X(K-sP)$.  This condition is equivalent to the existence of a divisor $D$ linearly equivalent to $K$ such that $D-(s-1)P$ is effective but $D-sP$ is not effective.  But this just means $D$ is effective and $s-1$ is the coefficient of $P$ in $D$.  The effective divisors which are linearly equivalent to $K$ are exactly the hyperplane sections of $X$ for its canonical embedding.  So our condition is equivalent to the existence of a hyperplane section of the canonical embedding that contains $P$ with multiplicity $s-1=j$, as desired.
A: Another way to think about the problem (which is essentialy what Eric Wofsey did) is to use the geometric Riemann-Roch. Being a gap means $dim|(j+1)p|=dim|jp|$ and by the geometric version of Riemann-Roch we have $\overline{\phi_K(jp)}=\overline{\phi_K((j+1)p)}-1$ , where $\overline{\phi_K(D)}$ is the intersection of all hyperplanes in $\mathbb{P}^{g-1}$ containing my divisor D. So in our case $\overline{\phi_K(jp)}$ is the set of all hyperplanes passing through p with multiplicity at least j and $\overline{\phi_K((j+1)p)}$ is the set of all hyperplanes passing through p with multiplicity at least $j+1$, hence our condition $\overline{\phi_K(jp)}=\overline{\phi_K((j+1)p)}-1$ implies that there must exists an hyperplane passing through p with multiplicity exactly j.
