Simplify and add list of all lychrel numbers under 10000

master
Micke Nordin 7 years ago
parent 72f2e7d1bf
commit 214100fb72

@ -1,6 +1,6 @@
#include <iostream>
#include <cstring>
#include <climit>
#include <climits>
#include "lychrel.hpp"
long long get_len (string a, string b) {

@ -0,0 +1,241 @@
196
295
394
493
592
689
691
788
790
879
887
978
986
1495
1497
1585
1587
1675
1677
1765
1767
1855
1857
1945
1947
1997
2494
2496
2584
2586
2674
2676
2764
2766
2854
2856
2944
2946
2996
3493
3495
3583
3585
3673
3675
3763
3765
3853
3855
3995
4079
4169
4259
4349
4439
4492
4494
4529
4582
4584
4619
4672
4674
4709
4799
4762
4764
4852
4854
4889
4899
4942
4944
4979
4994
5078
5168
5258
5348
5438
5491
5528
5581
5583
5618
5671
5673
5708
5761
5763
5798
5851
5853
5888
5941
5943
5978
5993
6077
6167
6257
6347
6437
6517
6607
6670
6672
6707
6760
6762
6797
6850
6852
6940
6942
6977
6992
7057
7076
7059
7149
7166
7239
7256
7329
7346
7419
7436
7491
7509
7526
7581
7599
7616
7671
7706
7761
7779
7796
7851
7886
7869
7941
7951
7959
7976
7991
8058
8075
8079
8089
8148
8165
8169
8179
8238
8255
8259
8269
8328
8345
8349
8359
8418
8435
8439
8449
8490
8508
8525
8529
8539
8580
8598
8615
8619
8629
8670
8688
8705
8709
8719
8760
8778
8809
8850
8868
8885
8889
8899
8940
8958
8975
8979
8989
8990
9057
9074
9078
9088
9147
9164
9168
9178
9237
9254
9258
9268
9327
9344
9348
9358
9417
9434
9438
9448
9507
9524
9528
9538
9597
9614
9618
9628
9687
9704
9708
9718
9777
9794
9798
9808
9867
9884
9888
9898
9957
9974
9978
9988
9999

@ -7,25 +7,19 @@
int main(int argc, char **argv)
{
string a = argv[1];
string b(a.rbegin(),a.rend());
string 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;
}
cout << "Starting with " << a;
string added = a;
long long it = 0;
do {
cout << "Iteration " << ++it << " currently working on " << added << endl;
a = added;
b = string(a.rbegin(),a.rend());
string b = string(a.rbegin(),a.rend());
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 << "Iteration " << ++it << " currently working on " << added << endl;
cout << "That consists of\n" << a << "\n+\n" << b << "\nand that it " << (is_palindrome(added) ? "is" : "is not") << " a palindrome." << endl;
cout << " " << added << " is a palindrome and was found after " << it << " iterations.\n";
return 0;
}

Loading…
Cancel
Save