How do you convert a simple looking formula and turn it into an algorithm? It's simple. Break stuff down into steps. That's what you're always told. There are actually a few more things to do.
1. If there are any constants in your program, declare them as such. This will make your life easier when you want to alter it slightly to produce different output.
2. If you can put together an operation on one line, chances are that you should. A single line operation is usually easier to debug also, since you don't have to go hunting for what does what in the long chain of operations.
3. If you can't seem to find a way to do what you want to do, it means your algorithm isn't simple enough.