Pythagoras triplet

import java.util.;
public class Main {
public static void main(String args[]) {
Scanner s = new Scanner(System.in);
long A = s.nextLong();
int k = 0 ;
long n = A
A ;
long i = 1 ;
long a = i ;
long b = A ;
if (A == 0){
System.out.println("-1");
}
else
while (b <= n){
if (bb - aa == n){
System.out.println(a + " " + b);
k++ ;
break ;
}
else if (bb - aa >= n){
a++ ;
}
else{
b++ ;
a = i ;
}
}
if (k == 0){
System.out.println("-1");
}
}
}
Why the two test cases not passing the code ? Pls help to correct the code .

@Sejalrathi,

You can use the following approach:

If n<0, n=1, n=2. Print -1 and return because squares aren’t possible for these numbers.
Now if n is even. We will simplify the Pythagorean equation.
a^2 + b^2 = c^2. Hence we manipulate the equation as a^2 = (c+b)(c-b). Now if the given number is even i.e. a is even, we can express it as product of 2 even numbers say 2 and (a^2)/2.

(a^2)/2 * 2 = (c-b)(c+b)
Hence c+b = 2 and c-b = (a^2)/2. Now solve for b and c and do similarly if given n is odd. (NOTE: I have taken a = n)

You can see this code: https://ide.codingblocks.com/s/184205
Also please use https://ide.codingblocks.com/ to share your code