Puzzle 40 | (Find missing Row in Excel)
We are given an excel sheet which contains integers from 1 to 50, including both. However, the numbers are in a jumbled form and there is 1 integer missing. You have to write a code to identify the missing integer. Only the logic is required.
We know that the sum of all the numbers from 1 to n is (n*(n+1)/2)
Therefore, sum of all the numbers from 1 to 50 is
50*(50+1)/2 (Here, n = 50) = 50*(51)/2 = 25*51 = 1275.
Therefore, all we need to do is to sum all the integers present in the file and subtract the sum from 1275. The difference between 1275 and this sum would give us the missing integer.
See this for code.
This puzzle is contributed by Feroz Baig. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
My Personal Notes arrow_drop_up
Please Login to comment...