Spectral window when FFT is not a power of 2 I am trying to better understand zero padding and the FFT. To do so, I am attempting to plot the spectrum of the Hann window function, i.e. 

$$ w(n) = \frac{1}{2}\left(1-\cos\left(\frac{2\pi (n+1/2)}{N}\right)\right) $$

To accomplish this, I did the following: 1) I created a series of points $n=0,1,...,49$ that I substituted into the hamming window function to get $w(n)$, 2) I zero-padded the data to $M=512$ to get $x(n)$, 3) I used the FFT function in R to compute the Fourier transform of $x(n)$, 4) I calculated the magnitude squared of the Fourier transform obtained in part 3). This gave me the following result:



I then repeated the above steps, but with $M=500$ instead of $M=512$ (i.e. I zero-padded to 500 instead of 512). This gave me the following result:



Why are these two spectra so different? Everything that I have read about the FFT seems to say that I should choose $M$ to be a power of 2 in order to reduce computation time. But I haven't found anything that explains why the spectrum should change as it does.

Any help would be appreciated... thanks!
500 is an exact integer multiple of the period of the cosine function used in your raised cosine window.  Therefore there are zeros in the spectrum at all multiples of the cosine's frequency (due to those basis vectors being exactly orthogonal).  512 is not an integer multiple of that cosine's period, so none of the correlations against the DFT basis vectors of a 512 length FFT will be zero (just small).  Thus the difference between the two spectrums.