#WSQ12

#include “BigIntegerLibrary.hh”
#include <iostream>
#include <string>
using namespace std;

BigInteger lychrel (BigInteger x){

string z = bigIntegerToString(x);
lychrel(z.begin(), z.end());
BigInteger lychrel = stringToBigInteger(z);
return lychrel;
}

int main() {
int inferior,superior, p, k, number, a=0;
int f=0, n=0;
BigInteger y, c=0, suma=0;

cout << “Dame el limite inferior”;
cin>>inferior;

cout<< “Dame el limite superior”;
cin>>superior;

for(c=inferior; c<=superior; c++){
for(BigInteger m=count; m<=count;m++){

y= lychrel(m); suma=y+c;}

if(c==y) {
n=n+1;
} else {
int times= 0;

BigInteger numero = c;
y=lychrel(numero);

while(times<30 && numero!=y){

number = numero+y;
y = lychrel(numero);
times = times+1;
}
if(times < 30){
a = a+1;
} else {
cout << “Lychrel found ” <<c<< endl;
f = f+1;
}
}
}

cout <<“The palindrom is: ” << n <<endl;
cout<<“Non lychrel become palindrom in one interacion: “<<a<<endl;
cout<<“The lychrel is: “<<f<<endl;

return 0;
}

CC BY-SA 4.0 #WSQ12 by perape is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.