You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
691 B

6 years ago
#include <iostream>
#include <cstring>
#include <climits>
6 years ago
#include "lychrel.hpp"
int main(int argc, char **argv)
{
string a = argv[1];
cout << "Starting with " << a;
string added = a;
6 years ago
long long it = 0;
do {
a = added;
string b = string(a.rbegin(),a.rend());
6 years ago
added = add(a,b);
if(added == "-1") {
cerr << "ERROR: adding error detected, we might have reached the end of our datatype or some how the two numbers don't have the same legth\n";
return 1;
}
it++;
} while(! is_palindrome(added));
cout << " " << added << " is a palindrome and was found after " << it << " iterations.\n";
6 years ago
return 0;
}