|
public class PerfectSquare{
public static void main(String args[]){
InputStream in= new InputStream(System.in);
int i,no;
boolean flag=false;
String str=in.readLine();
no=Integer.parseInt(str);
for(i=0;i<no/2;i++)
{
if(i*i==no)
{
System.out.println("The no is a perfect square..");
flag=true;
break;
}//if
}//for
if(!flag)
System.out.println("The no is not perfect square..");
}//main
}//class
You can also use the basic principle of perfect squares..
Only perfect squares have odd no of factors..
Eg: factors(25)= 1,5,25
|