Are these two methods for obtaining the mid point equivalent?

41 Views Asked by At

I was working on computer science problem on LeetCode website. The solution required that the midpoint be calculated between two numbers, lets call them start and end. Ultimately my solution passed the tests. The issue is that one of the other solutions I found had a similar solution, but it calculated the midpoint differently.

This is how I calculated it: mid = (start + end) / 2
This is how the other solution calculated it: mid = start + (end - start) / 2

Are these two functions equivalent? I tried to use my math skills, but they seem to have deteriorated over the decades. This is what I came up with so far, but just need some insight. (start + end) / 2 = start + (end - start) / 2
start + end = (start + (end - start)/2) * 2
start + end = 2 * start + (end - start)
start + end = start + end