Find max number of consecutive numbers in the list Edit on GitHub

You need to write a Perl sub get_max_consecutive_numbers.

All the arguments that are passed to the sub are whole numbers. You need to take the first argument and check all the other arguments. The result is the max number of consecutive first argument value in all the other arguments.

Here is an example of how the sub should work. The first argument is the number 3. All the other arguments are 1, 2, 3, 3, 4, 3. The maximum consecutive list of number 3 consist of two elements 3, 3, so the answer is 2.

print get_max_consecutive_numbers(3, 1, 2, 3, 3, 4, 3); # 2

Some more examples:

print get_max_consecutive_numbers(1, 1); # 1
print get_max_consecutive_numbers(1, 1, 2); # 1
print get_max_consecutive_numbers(1, 1, 1, 1); # 3
print get_max_consecutive_numbers(18, 19, 18, 18); # 2

The code you enter will be run in perl 5.30. The code is run with use utf8;, use strict; and use warnings;. You can use any library that is shipped with perl.