Though your code is fine, another thing to look is amount of division happening the code, Division is computationally expensive operation and as @Michael has suggested that it is redundant. So always try to minimise the multiplication and division operation in your code. You have mentioned that you are a beginner programmer. I believe it is a good practice to start familiarising your self with topics like Computational Complexity. Look [here][1] for computational complexity of mathematical functions [1]: https://en.wikipedia.org/wiki/Computational_complexity_of_mathematical_operations