2019-03-22 15:47:19 +01:00
|
|
|
extern crate num_bigint;
|
|
|
|
// extern crate num_traits;
|
|
|
|
|
|
|
|
use num_bigint::BigUint;
|
|
|
|
|
|
|
|
|
|
|
|
fn main()
|
|
|
|
{
|
|
|
|
let mut num = BigUint::from(0 as u8);
|
|
|
|
num = num + 277777788888899u128;
|
|
|
|
|
|
|
|
println!("{:?}", test(num));
|
|
|
|
}
|
|
|
|
|
|
|
|
fn test(input: BigUint) -> u8 {
|
|
|
|
let mut n = factorize(input);
|
|
|
|
let mut counter = 1;
|
2019-03-22 17:27:22 +01:00
|
|
|
while (n.to_str_radix(10).chars().count() > 1) {
|
2019-03-22 15:47:19 +01:00
|
|
|
n = factorize(n);
|
|
|
|
println!("n: {:?}", n);
|
|
|
|
counter += 1;
|
|
|
|
}
|
|
|
|
return counter;
|
|
|
|
}
|
|
|
|
|
|
|
|
fn factorize(input: BigUint) -> BigUint {
|
|
|
|
let string = input.to_str_radix(10);
|
|
|
|
let numbers: Vec<u8> = string.chars().map(|x| x as u8 - 48).collect();
|
|
|
|
numbers.into_iter().product::<BigUint>()
|
|
|
|
}
|