You are given a list/array of unsorted positive integers which you know to be the first whole numbers with one of them missing.
About how many operations are needed (as a minimum) to determine which number is missing?
Note: For the purposes of this problem, one operation is defined as an addition, subtraction, multiplication, division, or element comparison.
Just for fun : Can you use your algorithm to find the missing number in this list of 9999 of the first 10,000 whole numbers?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
We can find the sum of all of the numbers in the list in about n operations. Simply subtract this from 1 + 2 + 3 + … + n = 2 n ( n + 1 ) and we've found the missing number!
For the data set given, the missing number is 1 3 3 7 .