sub01's calculation might takes long cpu circle
if current > max max = current
else if current
worst the CPU instruction cost, 2 compare, 1 assignment
most case: 1 compare 1 assignment or 2 compare
sub01, your solution involves too many plus (which cost same as compare/assignment), multiplier(more expensive than compare), assignment
so I think amei's solution is more optimized.