why convert it into flow? Just wrap it up in a java service…
Create a java service, setup two string inputs, one string output. Generate the pipeline pull/push code.
Then all you need is to turn the strings into numbers and call the above method (which you convert to static and dump in the shared tab).
Or is this homework/interview question/a test?
If so, that might be defeating the purpose of seeing whether you can turn it into flow.