Yes, by using a for() loop. You can find a couple of variations over here. As a simple alternative you can also use the min/max functions in R or any other language like Python.