standard deviation

I am trying to write a function to calculate the standard deviation of a vector. I thought I had done it correctly but I get a standard deviation calculation that is not exactly accurate.
so here is what I have: