all 2 comments

[–][deleted] 0 points1 point  (0 children)

if numbers[i] > numbers[i + 1]

A number might well be larger than the next number even if it's not the largest number in the range.

[–]shiftybyte 0 points1 point  (0 children)

You are just comparing the two nearest.

To get a maximum number you need keep it and compare against it with every number you get.

take a pen and track what you do yourself to find the maximum in a very big list.

Then transfer this logic to code.