nines_and_zeros.rs 460 B

1234567891011121314151617181920
  1. use std::env;
  2. fn main() {
  3. if env::args().len() != 2 {
  4. println!("Usage: {} divisor", env::args().nth(0).unwrap());
  5. return;
  6. }
  7. let divisor = env::args().nth(1).unwrap().parse::<u64>().ok().expect("Input is not a number");
  8. let mut num: u64 = 0;
  9. let mut s: u64 = 9;
  10. while s % divisor != 0 {
  11. num += 1;
  12. s = format!("{:b}", num).replace("1", "9").parse::<u64>().unwrap();
  13. }
  14. println!("Found: {}", s);
  15. }