Expression for discrete fourier transform of linear ramp
There is indeed a better way; you can derive the analytical expression for the DFT of a ramp. Let's start with the discrete-time Fourier transform (DTFT) of a finite length sequence (i.e., the sequence is zero outside the interval $[0,N-1]$):

$$X(e^{j\omega})=\sum_{n=0}^{N-1}x[n]e^{-jn\omega}\tag{1}$$

We also need the DTFT correspondence

$$nx[n]\Longleftrightarrow j\frac{dX(e^{j\omega})}{d\omega}\tag{2}$$

The DTFT of the constant signal $x[n]=a$, $n\in [0,N-1]$ (and zero otherwise) is

$$X(e^{j\omega})=a\sum_{n=0}^{N-1}e^{-jn\omega}=\begin{cases}aN,&amp;\quad\omega=0\\\displaystyle a\frac{1-e^{-jN\omega}}{1-e^{-j\omega}},&amp;\quad\text{otherwise}\end{cases}\tag{3}$$

From $(2)$ and $(3)$ we get

$$\begin{align}a\sum_{n=0}^{N-1}ne^{-jn\omega}&amp;=j\frac{dX(e^{j\omega})}{d\omega}\\&amp;=-a\frac{Ne^{-jN\omega} (1-e^{-j\omega})-(1-e^{-jN\omega})e^{-j\omega}}{(1-e^{-j\omega})^2},\quad\omega\neq 0\end{align}\tag{4}$$

which is the DTFT of the given sequence. For $\omega=0$ we simply have

$$a\sum_{n=0}^{N-1}n=a\frac{N(N-1)}{2}\tag{5}$$

Now we only need to remember that for finite length sequences, the DFT is a sampled version of the DTFT with $\omega_k=2\pi k/N$. From $(4)$ and $(5)$ we obtain

$$\text{DFT}_N\{an\}[k]=\begin{cases}\displaystyle a\frac{N(N-1)}{2},&amp;\quad k=0\\-a\displaystyle\frac{N}{1-e^{-j2\pi k/N}},&amp;\quad k\in[1,N-1]\end{cases}\tag{6}$$