Pythagoras Triplet

not sure how to print this since N is very large no and 6 8 10 which are multiples of 3 4 5 are valid triplets to?

code written
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner scan=new Scanner(System.in);
int N=scan.nextInt();

	for(int X=N;X<=100000;X++)
	{
		boolean flag=false;
		for(int Y=N;Y<=100000;Y++)
		{
		
			
			if((N*N)==(Y*Y-X*X))
			{
				
				for(int i=2;i<=10;i++)
				{
					if(X%i==0&&N%i==0&&Y%i==0)
					{

// System.out.println(X+" “+Y);
flag=true;
System.out.println(”-1");
break;
}
}
if(flag==false)
{
System.out.println(X+" "+Y);

					flag=true;
					break;
				}
				
			}
				
				
			
			
			
			if(flag==true)
			{
				break;
			}
		}
		
		if(flag==true)
		{
			break;
		}
	
	}
}

}

see if users enter 6 then you need to print 6 8 10 only…see your codes complexity is more than the desired complexity so here is an approach…

Pythagorean triplet are of form m^2-n^2, 2mn , m^2+n^2…in this ques you are given a value…assume that this value can be of first form or second form…so if the given value say ‘a’ is even then you can equate it to 2mn…mn=a/2…there can be various values of (m,n)…you can take any value of (m,n)… one possible value can be m=a/2 and n=1…else if the given value ‘a’ is odd equate it to m^2-n^2…by factorization m^2-n^2=(m+n)(m-n)…(m+n)(m-n)=a…there could be many values of (m,n)…you can chose any one…(m+n)=a and (m-n)=1 solving these two equations we get m=(a+1)/2 and n=(a-1)/2…as you know the values of m,n rest of the two pythagorean triplets can be found…

so according to the comment if i give 6 it should print 8 and 10 and ide accepts it as output am i rit?

and so when is -1 printed since almost all numbers comes under pythagorous triplets

consider if your input is 2 or 1