Problem in Challenge Pythagoras Triplet

import java.util.Scanner;

public class Main {

public static void main(String args[]) {

	Scanner scn = new Scanner(System.in);
	int n=scn.nextInt(),count=0;
	
	for(int i=1;i<1000000000&&n>0;i++) {
		if(count==1)
			break;
		for(int j=1;j<i;j++) {
			
			if(i*i==j*j+n*n||j*j==n*n+i*i||n*n==i*i+j*j) {
				System.out.println(j+" "+i);
				count++;
			}
		}
	}
    if(count==-1)
        System.out.print(-1);
	
}

}

Whats wrong in the code?


Please check this.

import java.util.Scanner;

public class Main {

public static void main(String args[]) {

	Scanner scn = new Scanner(System.in);
	int n=scn.nextInt(),count=0;
	
	for(int i=1;i<1000000000&&n>0;i++) {
		if(count==1)
			break;
		for(int j=1;j<i;j++) {
			
			if(i*i==j*j+n*n||j*j==n*n+i*i||n*n==i*i+j*j) {
				System.out.println(j+" "+i);
				count++;
			}
		}
	}
    if(count==-1)
        System.out.print(-1);
	
}
}

If i give input 1, it should give -1 as output but it is not
Also, you can reduce the complexity as it is given that a leg is given. So hypotenuse must be higher than it So you need not to start the loop from 1