errr
This commit is contained in:
		
							parent
							
								
									aceac2b4a6
								
							
						
					
					
						commit
						937c63a985
					
				
							
								
								
									
										67
									
								
								src/main.rs
									
									
									
									
									
								
							
							
						
						
									
										67
									
								
								src/main.rs
									
									
									
									
									
								
							@ -3,13 +3,70 @@ extern crate num_bigint;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
use num_bigint::BigUint;
 | 
					use num_bigint::BigUint;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct Counter {
 | 
				
			||||||
 | 
					    length: u64,
 | 
				
			||||||
 | 
					    prefix: u8,
 | 
				
			||||||
 | 
					    last: BigUint,
 | 
				
			||||||
 | 
					    total: BigUint
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
fn main()
 | 
					impl Counter {
 | 
				
			||||||
{
 | 
					    fn new() -> Counter {
 | 
				
			||||||
 | 
					        Counter {length: 1, prefix: 0, last: BigUint::from(0u8), total: BigUint::from(0u8)}
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl Iterator for Counter {
 | 
				
			||||||
 | 
					    type Item = BigUint;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    fn next(&mut self) -> Option<BigUint> {
 | 
				
			||||||
 | 
					        let old = self.last;
 | 
				
			||||||
 | 
					        let old_str = old.to_str_radix(10);
 | 
				
			||||||
 | 
					        let mut new_str = old_str;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        let mut carry = true;
 | 
				
			||||||
 | 
					        let mut index = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        while carry != true {
 | 
				
			||||||
 | 
					            match old_str[old_str.chars().count() - 1 - index] {
 | 
				
			||||||
 | 
					                '5' => {carry = false; new_str[new_str.chars().count() - 1 - index] = '7'},
 | 
				
			||||||
 | 
					                '7' => {carry = false; new_str[new_str.chars().count() - 1 - index] = '8'},
 | 
				
			||||||
 | 
					                '8' => {carry = false; new_str[new_str.chars().count() - 1 - index] = '9'},
 | 
				
			||||||
 | 
					                '9' => {carry = true; index += 1; new_str[new_str.chars().count() - 1 - index + 1] = '5'}
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        if carry == true {
 | 
				
			||||||
 | 
					            self.prefix += 1;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        let new_string = String::new();
 | 
				
			||||||
 | 
					        new_string.push_str(match self.prefix {
 | 
				
			||||||
 | 
					            0 => "",
 | 
				
			||||||
 | 
					            1 => "2",
 | 
				
			||||||
 | 
					            2 => "3",
 | 
				
			||||||
 | 
					            3 => "4",
 | 
				
			||||||
 | 
					            4 => "6",
 | 
				
			||||||
 | 
					            5 => "26"
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					        new_string.push_str(new_str);
 | 
				
			||||||
 | 
					        return BigUint::from_str(new_string);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					fn main() {
 | 
				
			||||||
    let mut num = BigUint::from(0 as u8);
 | 
					    let mut num = BigUint::from(0 as u8);
 | 
				
			||||||
    num = num + 277777788888899u128;
 | 
					    // num = num + 277777788888899u128;
 | 
				
			||||||
 | 
					    let mut max: u8 = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    println!("{:?}", test(num));
 | 
					    let mut n = test(num.clone());
 | 
				
			||||||
 | 
					    while n < 10 {
 | 
				
			||||||
 | 
					        n = test(num.clone());
 | 
				
			||||||
 | 
					        if (n > max) {
 | 
				
			||||||
 | 
					            max = n;
 | 
				
			||||||
 | 
					            println!("{}: {}", n, num);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        num += 1u8;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
fn test(input: BigUint) -> u8 {
 | 
					fn test(input: BigUint) -> u8 {
 | 
				
			||||||
@ -17,7 +74,7 @@ fn test(input: BigUint) -> u8 {
 | 
				
			|||||||
    let mut counter = 1;
 | 
					    let mut counter = 1;
 | 
				
			||||||
    while (n.to_str_radix(10).chars().count() > 1) {
 | 
					    while (n.to_str_radix(10).chars().count() > 1) {
 | 
				
			||||||
        n = factorize(n);
 | 
					        n = factorize(n);
 | 
				
			||||||
        println!("n: {:?}", n);
 | 
					        // println!("n: {:?}", n);
 | 
				
			||||||
        counter += 1;
 | 
					        counter += 1;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return counter;
 | 
					    return counter;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user