Add check for if the first digit is smaller than 5

master
trivernis 5 years ago
parent 000a15106c
commit 295f13d5bd

@ -1,81 +0,0 @@
66
11
99
666
44
555
444
77
22
333
222
55
111
999
1111
33
2222
777
3333
4444
88
6666
888
5555
7777
9999
11111
8888
22222
33333
44444
66666
55555
102564
77777
88888
99999
111111
153846
128205
142857
222222
205128
230769
444444
333333
555555
666666
888888
777777
999999
1111111
2222222
4444444
3333333
6666666
5555555
8888888
7777777
9999999
11111111
22222222
44444444
33333333
66666666
55555555
88888888
77777777
99999999
111111111
22
222222
333333333
444444444
666666666
555555555
777777777
888888888
999999999
1111111111
2222222222

@ -63,12 +63,14 @@ fn get_rotatable(tx: Sender<BigUint>, sen_time: Sender<bool>, start: u64, end: B
while num < end { while num < end {
if num.is_odd() || !(&num % 10 as u64).is_zero() { if num.is_odd() || !(&num % 10 as u64).is_zero() {
let mut digits = ubig_digits(num.clone()); let mut digits = ubig_digits(num.clone());
if digits.first() >= digits.last()
&& !(digits[0] % 2 == 0 && digits[1] % 2 != 0) {
digits.rotate_left(1);
let first = *digits.first().unwrap() as u64; let first = *digits.first().unwrap() as u64;
let last = *digits.last().unwrap() as u64;
if (last < 5 || first == last)
&& first >= last
&& !(first % 2 == 0 && digits[1] % 2 != 0) {
digits.rotate_left(1);
let num_rotated = ubig_from_digits(digits); let num_rotated = ubig_from_digits(digits);
if (first == 0 || (&num_rotated % first).is_zero()) && (&num_rotated % &num).is_zero() { if (&num_rotated % &num).is_zero() {
let _ = tx.send(num.clone()); let _ = tx.send(num.clone());
} }
} }

Loading…
Cancel
Save