Commit c4178402 authored by David Rothbauer's avatar David Rothbauer :speech_balloon:
Browse files

Add new file

parents
Pipeline #984 failed with stages
Showing with 40 additions and 0 deletions
+40 -0
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
int largestP = 0;
int num = 0;
int maxNum = 9999;
bool isPalindrome(int num) {
string s = to_string(num);
int maxIndex = s.length() - 1;
for (int i = 0; i <= maxIndex/2; i++) {
if (s[i] != s[maxIndex - i]) {
return false;
}
}
return true;
}
int main()
{
for (int a = 0; a <= maxNum; a++) {
for (int b = 0; b <= maxNum; b++) {
num = a * b;
if (isPalindrome(num) && num > largestP) {
largestP = num;
cout << "Found: " << largestP << "\n";
}
}
}
cout << "\n" << "Nasel: " << largestP << "\n";
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment