If we know logic how do we write code for it

For an example

quotient = 987 / 10 --> 98

remainder = 987 % 10 --> 7 -> first number

quotient = 98 / 10 --> 9 --> third number

remainder = 98 % 10 --> 8 --> second number

first ->second -> third = 7 8 9

I do not want the code, I want to find out way how I can write my code if I know the logic.