Skip to content

Instantly share code, notes, and snippets.

@yask123
Created August 12, 2013 08:43
Show Gist options
  • Save yask123/6209202 to your computer and use it in GitHub Desktop.
Save yask123/6209202 to your computer and use it in GitHub Desktop.
public class Palin
{
public static void main(String args[])
{
Palin ob = new Palin();
int max=0;int tmp=0;
for(int i=100;i<999;i++)
{
for(int j=100;j<999;j++)
{
tmp=i*j;
if(max<tmp)
{
if(ob.checkPalin(max))
{
max=i*j;
}
}
}
}
System.out.println("The result is "+max);
//This is for testing purpose only
int n=1234;
int r=0;
int rev=0;
while(n>0)
{
r=n%10;
rev=rev*10+r;
n=n/10;
}
System.out.println(" ~ Test"+rev);
}
boolean checkPalin(int n)
{
int r=0;
int rev=0;
int temp=n;
while(temp>0)
{
r=temp%10;
rev=rev*10+r;
temp=temp/10;
}
if(n==rev)
{
System.out.println("I am thinking "+n+" is palin , is it?");
return(true);
}
else
{
return(false);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment