Menu
Coddy logo textTech

Recap - Dynamic Input

Part of the Fundamentals section of Coddy's Ruby journey — lesson 47 of 88.

challenge icon

Challenge

Easy

Read a count n from input, followed by n integers. Find and print the largest number among the inputs.

The first input is the count of numbers to follow. Then read that many numbers using a loop and track the maximum value.

For example, if the inputs are:

4
7
2
9
5

The output should be:

9

If the inputs are:

3
15
8
22

The output should be:

22

Try it yourself

# Read the count of numbers
n = gets.to_i

# TODO: Write your code below
# Read n numbers and find the largest one


# Output the result
puts max

All lessons in Fundamentals