Find number of candidates in the Exam
Given the last rank ‘L’ and the number of candidates at the last rank ‘T’, the task is to find the total number of candidates in the Exam.
Input: L = 5, T = 1 Output: 5 Input: L = 10, T = 2 Output: 11
Hey! Looking for some great resources suitable for young ones? You've come to the right place. Check out our self-paced courses designed for students of grades I-XII.
Start with topics like Python, HTML, ML, and learn to make some games and apps all with the help of our expertly designed content! So students worry no more, because GeeksforGeeks School is now here!
- Suppose L = 5 and T = 2.
- Then there can be many possible rank combinations, like 1, 2, 3, 3, 5, 5.
- So now in this, as you can see, the last rank is 5 and there are 2 students at rank 5,
- Therefore, the total number of candidates is 6.
- This can be understood by a simple formula:
Below is the implementation of the above approach.