Q. There is an exam with N problems. For each problem, a participant can either choose to answer the problem, or skip the problem. If the participant chooses to answer the problem and gets it correct, the participant is awarded X points. If the participant chooses to answer the problem but answers it incorrectly, 1 point is deducted from their score. If the participant skipped the problem, there is no change to their score. For each of the following values of N and X, compute the number of distinct scores the participant could obtain in the exam:
(a) N = 7, X = 4 (sol: 30)
(b) N = 15, X = 18 (sol: 136)
(c) N = 30, X = 20 (sol: 441)
I have made a formula for solving this question, which is $\frac{(N+1)(N+2)}{2}-\frac{(N-X)(N+1-X)}{2}$, and for $X >=N, N-X$ will be considered $0$
I made this formula by observing certain patterns, and its giving me the required solution.
I am still not satisfied with this formula
Can you guys please point out any mistakes, and also share more elegant solutions if you have?
Thank you