In what language? What is the exact code you used?
In C/C++, the sin() function uses radians, so your formula does not work. You'd need to put PI/n in the arguments, but by then you would have already defined PI. :)