From 295f13d5bd00f796babb9e3e09272831e08755be Mon Sep 17 00:00:00 2001 From: trivernis Date: Sun, 9 Feb 2020 19:24:27 +0100 Subject: [PATCH] Add check for if the first digit is smaller than 5 --- rotatable.txt | 81 --------------------------------------------------- src/main.rs | 10 ++++--- 2 files changed, 6 insertions(+), 85 deletions(-) delete mode 100644 rotatable.txt diff --git a/rotatable.txt b/rotatable.txt deleted file mode 100644 index 33aa26e..0000000 --- a/rotatable.txt +++ /dev/null @@ -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 diff --git a/src/main.rs b/src/main.rs index cdd57ac..523e877 100644 --- a/src/main.rs +++ b/src/main.rs @@ -63,12 +63,14 @@ fn get_rotatable(tx: Sender, sen_time: Sender, start: u64, end: B while num < end { if num.is_odd() || !(&num % 10 as u64).is_zero() { let mut digits = ubig_digits(num.clone()); - if digits.first() >= digits.last() - && !(digits[0] % 2 == 0 && digits[1] % 2 != 0) { + 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 first = *digits.first().unwrap() as u64; 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()); } }