#C10970. Find the Missing Number in a Sequence
Find the Missing Number in a Sequence
Find the Missing Number in a Sequence
Given a single line of space-separated integers in ascending order, one number in the complete sequence is missing. Your task is to identify and output this missing number.
For example, if the input is "1 2 3 5 6", then the missing number is 4 because the natural consecutive order should be 1, 2, 3, 4, 5, 6.
Note: The input will always have at least two numbers and exactly one missing number in the sequence.
inputFormat
The input consists of a single line containing space-separated integers in ascending order. All integers are guaranteed to represent a nearly consecutive sequence with exactly one missing number between the smallest and largest element.
Example: 1 2 3 5 6
outputFormat
Output the missing integer in the sequence.
Example Output: 4
## sample1 2 3 5 6
4