I see the problem. d is the depreciation rate, expressed as a percentage, if you want to use it in the program, you HAVE to do d=d/100. This will convert the rate into decimal, and then use it in your program.
EDIT: Yeah, Peter87, you're right.. I made a typo... Thanks...