You start by working out the mathematical formula. From that you should be able to write out the steps required to use that formula to get an answer. And from those steps you can write the code.

Also the section headed "What I have tried:", is for you to show what you have done and where any problems may occur. It is not there just to repeat the question.

15,615,280 members