As you can see in the code below, two different mathematical processes are represented by the two functions. Try to decompose the repeated pattern in code to another function. Name the new function calculateHalf.
To solve this task, you must not delete or modify any code within the
main function. Your only objective is to write the code for the calculateHalf function stated above.