The usual way to start is thinking how you would do it by hand. Then try to imagine talking your gran into modelling it by hand over the phone. What do you tell her so that the result is correct? It’s hopefully a short step from those instructions to programming code, and there’s plenty of people who can help with that final translation. As it is, your question is far too broad to allow for an answer.