3 test case not working

Can you please check this pythagorean triplet code , I don’t understand why test case are failing

@bhavik911,
Your logic is correct.
For input use long as well.

Use:

		long n = scanner.nextLong();

Instead of using:

		int n = scanner.nextInt();

Thanks. It works now .
Can you also tell me why are we not considering that if n is even it can also be equal to m^2 -n^2?

@bhavik911,
Umm, not sure what exactly you are trying to say, can you give an example of the same? And, this problem is more about algebra than anything else. I would suggest that you try and write the equations on a paper.

I mean here we are only considering the case that when the input given is even we are directly mapping it to the value 2mn , but there can also be a case where this even no might be equal to m^2 -n^2, why are we not considering this case

@bhavik911,
2m *n will always be even because it is multiplied by 2. The final answer won’t change. you can try it yourself.

like as we are not considering that case , then if we give n =12 as input,
we get 35 and 37 as output, why don’t we get 5 and 13?
That’s because we don’t consider that case , right?

@bhavik911,
As mentioned in the question:

Output Format

Two numbers X and Y denoting the rest of the numbers of the Pythagorean triplet in increasing order. 

Hence that case is ruled out.

Yeah , doesn’t that mean X and Y should be in increasing order just, its not that X should be greater than N?
Because if you givr input as 3 it will give us 4 and 5.
but if we givr input as 4, it will give input as 3 and 5, so that line is not followed here actually

@bhavik911,
That’s a great point you have made there. But again I will have to quote the question condition, it says we are given one of the legs of the triangle.

Hence out of the 2 sides and the hypotenuse, we need to find 1 side and the hypotenuse.

Yeah i understand you but i still don’t understand what’s wrong with 12 5 and 13??

@bhavik911,
Nothing is wrong with that. We are writing for a general case. Of course a number can have multiple triplets but we need a method to generalize it for all numbers.

Okay yeah I get it
thanks