palindromic number

hello friends,
recently i have started working on projecteular.net which tests our programming skill... so i have created few programs... those codes are here..one after other
question:
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
Find the largest palindrome made from the product of two 3-digit numbers.

answer:
#include
#include
void main()
{
 long int d0,d3,d2,d1,d5,d4,i,j,l,max=0;;
 clrscr();
 for(l=999;l>100;l--)
 for(i=999;i>100;i--)
  {
   j=l*i;
// j=986689;
   d5=(j%10);
   d4=((j-d5)%100)/10;
   d3=((j-d5-d4)%1000)/100;
   d2=((j-d5-d4-d3)%10000)/1000;
   d1=((j-d5-d4-d3-d2)%100000)/10000;
   d0=((j-d5-d4-d3-d2-d1)%1000000)/100000;
   if(d0==d5)
    if(d1==d4)
     if(d2==d3)
      {
       printf("l=%ld,i=%ld,j=%ld\n",l,i,j);
       if(max
       max=j;
      }
  }
 printf("max is %ld",max);
 getch();
}

Answer:906609

posted under , |

0 comments:

Newer Post Older Post Home

About Me

My photo
Hi everyone,myself Alagappan...electronic and communication engg. student... living in madurai... interested in everything... want to achieve something great in my lifetime...

Followers


Recent Comments