Created
November 10, 2014 02:23
-
-
Save shohan4556/028a79859f7f6a5b350b to your computer and use it in GitHub Desktop.
project euler problem 04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int reverse(int n){ | |
int reversed=0; | |
while(n>0){ | |
reversed=10*reversed+(n%10); | |
n=n/10; | |
} | |
return reversed; | |
} | |
int is_pal(int n){ | |
if(n==reverse(n)) | |
return n; | |
else | |
return 0; | |
} | |
int main() | |
{ | |
int lar_pal=0; | |
int a=999;int b; | |
while(a>100){ | |
b=999; | |
while(b>=a){ | |
if(a*b<=lar_pal) | |
break; | |
if(is_pal(a*b)) | |
lar_pal=a*b; | |
b--; | |
} | |
a--; | |
} | |
printf("%d\n",lar_pal); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment