A fine attempt, but let us not forget that you've left out at least two possibilities:

 1) Use of rests/durations: Rests and durations are important in melody making, otherwise, you'll end up sounding like some weird electronic music or a Steve Reich piece. This significantly increases the number of melodies you can get, each note can be held out from anywhere from the 32 or so quavers you define your melody to last, and that is a combinatorial problem my brain is too tired to figure out right now exactly. I think it's something along the lines of (32 * 13) permute 32: This you get from pretending all your possible notes were hand-painted balls in a big vat, which makes ((12notes + space)* 32max), and then you select 32 of these and include the permutations. I think I'm right. Anyway, it's a larger number.

2) Melodies don't always stay within an octave: Think, let's say, OK, a slighty obscure example - Prokofiev's piano sonata no. 6, 3rd movement. The arpegiated a-minor melody comes in, mucks around a bit, does it's thing, and then all of a sudden the tail end of the melody gets carried upwards in ribbons and ends up getting placed in the same spot an octave higher. Sure, while the release date of the next recording of the Prokofiev sonata no. 6 does not exactly have Justin Timberlake crossing out squares in his calendar, that doesn't mean this happens rarely. For instance, you know that bit in a pop song, where everything goes higher? Think Mariah Carey's "Can't live", or most Celine Dion songs. It's a modulation upwards, I think by a perfect fifth in most cases. I don't think you couldn't call that entire stretch a melody, and I think the lowest and highest notes in that set will probably poke outside the 1 octave range.

 

Melody is a hard thing to define, even definitions that seem academic come up in real music, see brain-liquefying modern music compositions. In my estimation, for all practical purposes there are probably an infinite number of melodies. A friend said that there are more chess games possible than atoms in the universe, and I have another friend that made music out of chess games. Monophonic mostly, I think. Ergo, there are at least as many 'melodies' as there are atoms in the universe.