Showing failed case

my code : https://ide.codingblocks.com/s/385629
here after clicking on submit it showed wrong ans for case 2 and 3 . but when i downloaded these test cases and compiled i got same ans as written in solution of these test cases. plz help.

Hello @pratik.win please wait i will see and tell you.

ok sir plz help me. i took s = n/x because in worst case too these many will get schlp

@pratik.win i have corrected your code and now it is printing the correct result and passing all the test cases.


s should be 1 and ans should be initialised as 0.
Happy Learning!!

sir but plz check my earlier code and complie it with test case 2 & 3 it will give same ans as written in respective testcases

@pratik.win there are many test cases which will give wrong answer for your code:
actually the test cases are shuffled as well.
so i cannot say.
but can you prove how starting s=n/2 will always give you correct answer.
if you are starting from n/2 then if any test case your answer is not updated so in that test case the answer evaluated will be n/2 only as you have also initialised your answer variable as n/2 only.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.