Here is my code on C (Brute force), the result was out after 0.172s.
#include <stdio.h> #include <stdlib.h> int palindrome(long x) { int i,j=0; char ch[7]; sprintf(ch,"%ld",x); char ch1[7]=""; for(i=strlen(ch)-1;i>=0;i--,j++) { ch1[j]=ch[i]; } if(strcmp(ch,ch1)==0) return 1; return 0; } int main() { int i,j; long s,max=100*100; for(i=100;i<=999;i++) { for(j=100;j<=999;j++) { s=i*j; if (palindrome(s) && s>max) max=s; } } printf("Result = %ld",max); }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Here is my code on C (Brute force), the result was out after 0.172s.