The num = are correct, so far as I can tell. I have no idea what you want f(n) to be, so who knows about that.