This is my solution c++ solution
So, I already know what’s the problem with my solution. for bigger values of N
Let’s say N = 1543483483434 and M = 39 my code is giving output-> -1.
because the formula I came up with is ((N*(N/2))+N/2) for even numbers.
so, as you can see this big number is getting multiplied by itself making the number super big. And the number becomes negative because of the cycle it goes through. Any suggestion? How can I fix this? Without using BigInteger!!