/
WSQ11 - Yo Soy 196
58 lines (45 loc) · 1.02 KB
/
WSQ11 - Yo Soy 196
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#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 << "Teclee el limite inferior";
cin>>inferior;
cout<< "Teclee 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;
}