For one, I don't see where you're calculating the number's factorial.

Also please wrap your code in
tags so that it retains its formatting and is easier to read.