In C language
Assignment
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.
Note: this is Project Euler's problem number 4.
Functional Requirements
Nonfunctional Requirements
Sample run
913, 993, 906609
#include <stdio.h>
int palindrome(int number);
int main() {
int largest = 0;
for (int i = 100; i <= 999; i++) {
for (int j = 100; j <= 999; j++) {
if (i*j==palindrome(i*j) && i*j > largest)
largest = i*j;
}
}
printf("913,993,""%d",largest);
return 0;
}
int palindrome(int number) {
int temp = 0;
while (number > 0) {
temp = temp * 10 + number %
10;
number = number / 10;
}
return temp;
}
Get Answers For Free
Most questions answered within 1 hours.