<commit_before>#[allow(dead_code)]
fn is_prime(num: int) -> bool {
    let sqrt_num = (num as f64).sqrt() as int;
    for divisor in range(2i, sqrt_num + 1) {
        if num % divisor == 0 {
            return false;
        }
    }
    return true;
}

#[allow(dead_code)]
fn is_prime2(num: int) -> bool {
    let sqrt_num = (num as f64).sqrt() as int;
    if num % 2 == 0 {
        return num == 2;
    }
    for divisor in std::iter::count(3i, 2).take_while(|x| *x <= sqrt_num) {
        if num % divisor == 0 {
            return false;
        }
    }
    return true;
}

#[allow(dead_code)]
fn is_prime3(num: int) -> bool {
    let sqrt_num = (num as f64).sqrt() as int;
    if num % 2 == 0 {
        return num == 2;
    }
    if num % 3 == 0 {
        return num == 3;
    }
    for k in std::iter::count(6i, 6).take_while(|x| *x - 1 <= sqrt_num) {
        if num % (k - 1) == 0 {
            return num == k - 1;
        }
        if num % (k + 1) == 0 {
            return num == k + 1;
        }
    }
    return true;
}

#[allow(dead_code)]
fn is_prime4(num: int) -> bool {
    let sqrt_num = (num as f64).sqrt() as int;
    let first_primes = [2i, 3, 5, 7, 11, 13, 17, 19, 23];
    for prime in first_primes.iter() {
        if num % *prime == 0 {
            return num == *prime;
        }
    }
    for divisor in std::iter::count(3i, 2).take_while(|x| *x <= sqrt_num) {
        if num % divisor == 0 {
            return false;
        }
    }
    return true;
}

fn is_prime_(num: int) -> bool {
    return is_prime3(num);
}

#[allow(dead_code)]
fn sum_of_primes_below(limit: int) -> int {
    let mut sum = 0i;
    for n in range(2i, limit) {
        if is_prime_(n) {
            sum += n;
        }
    }
    return sum;
}

#[allow(dead_code)]
fn sum_of_primes_below2(limit: int) -> int {
    let mut prime_sum = 0i;
    if limit > 2 {
        prime_sum += 2
    }
    if limit > 3 {
        prime_sum += 3
    }
    for k in std::iter::count(6i, 6).take_while(|k| *k - 1 < limit) {
        if is_prime_(k - 1) {
            prime_sum += k - 1
        }
        if k + 1 < limit && is_prime_(k + 1) {
            prime_sum += k + 1
        }
    }
    return prime_sum;
}

#[allow(dead_code)]
fn sum_of_primes_below3(limit: int) -> int {
    if limit <= 2 {
        return 0;
    }
    let mut prime_counters = vec![(2i, 0i)];
    let mut current_num = 3i;
    let mut sum = 2i;
    while current_num < limit {
        let mut seen_divisor = false;
        for pc in prime_counters.mut_iter() {
            let (prime, offset) = *pc;
            let new_offset = (offset+1) % prime;
            if new_offset == 0 {
                seen_divisor = true;
            }
            *pc = (prime, new_offset)
        }
        if !seen_divisor {
            prime_counters.push((current_num, 0));
            sum += current_num;
        }
        current_num += 1;
        println!("{}% done", 100*current_num/limit);
    }
    return sum
}

#[allow(dead_code)]
fn sum_of_primes_below4(limit: int) -> int {
    if limit <= 2 {
        return 0;
    }
    if limit <= 3 {
        return 2;
    }
    if limit <= 5 {
        return 5;
    }
    let mut prime_counters = vec![(2i, 1i), (3i, 1i)];
    let mut current_num = 5i;
    let mut sum = 5i;
    while current_num < limit {

        let mut seen_divisor = false;
        for pc in prime_counters.mut_iter() {
            let (prime, offset) = *pc;
            let new_offset = (offset+4) % prime;
            if new_offset == 0 {
                seen_divisor = true;
            }
            *pc = (prime, new_offset)
        }
        if !seen_divisor {
            prime_counters.push((current_num, 0));
            sum += current_num;
        }

        current_num += 2;
        if current_num < limit {
            seen_divisor = false;
            for pc in prime_counters.mut_iter() {
                let (prime, offset) = *pc;
                let new_offset = (offset+2) % prime;
                if new_offset == 0 {
                    seen_divisor = true;
                }
                *pc = (prime, new_offset)
            }
            if !seen_divisor {<commit_msg>euler: problem10 in rust; use new method name<commit_after>#[allow(dead_code)]
fn is_prime(num: int) -> bool {
    let sqrt_num = (num as f64).sqrt() as int;
    for divisor in range(2i, sqrt_num + 1) {
        if num % divisor == 0 {
            return false;
        }
    }
    return true;
}

#[allow(dead_code)]
fn is_prime2(num: int) -> bool {
    let sqrt_num = (num as f64).sqrt() as int;
    if num % 2 == 0 {
        return num == 2;
    }
    for divisor in std::iter::count(3i, 2).take_while(|x| *x <= sqrt_num) {
        if num % divisor == 0 {
            return false;
        }
    }
    return true;
}

#[allow(dead_code)]
fn is_prime3(num: int) -> bool {
    let sqrt_num = (num as f64).sqrt() as int;
    if num % 2 == 0 {
        return num == 2;
    }
    if num % 3 == 0 {
        return num == 3;
    }
    for k in std::iter::count(6i, 6).take_while(|x| *x - 1 <= sqrt_num) {
        if num % (k - 1) == 0 {
            return num == k - 1;
        }
        if num % (k + 1) == 0 {
            return num == k + 1;
        }
    }
    return true;
}

#[allow(dead_code)]
fn is_prime4(num: int) -> bool {
    let sqrt_num = (num as f64).sqrt() as int;
    let first_primes = [2i, 3, 5, 7, 11, 13, 17, 19, 23];
    for prime in first_primes.iter() {
        if num % *prime == 0 {
            return num == *prime;
        }
    }
    for divisor in std::iter::count(3i, 2).take_while(|x| *x <= sqrt_num) {
        if num % divisor == 0 {
            return false;
        }
    }
    return true;
}

fn is_prime_(num: int) -> bool {
    return is_prime3(num);
}

#[allow(dead_code)]
fn sum_of_primes_below(limit: int) -> int {
    let mut sum = 0i;
    for n in range(2i, limit) {
        if is_prime_(n) {
            sum += n;
        }
    }
    return sum;
}

#[allow(dead_code)]
fn sum_of_primes_below2(limit: int) -> int {
    let mut prime_sum = 0i;
    if limit > 2 {
        prime_sum += 2
    }
    if limit > 3 {
        prime_sum += 3
    }
    for k in std::iter::count(6i, 6).take_while(|k| *k - 1 < limit) {
        if is_prime_(k - 1) {
            prime_sum += k - 1
        }
        if k + 1 < limit && is_prime_(k + 1) {
            prime_sum += k + 1
        }
    }
    return prime_sum;
}

#[allow(dead_code)]
fn sum_of_primes_below3(limit: int) -> int {
    if limit <= 2 {
        return 0;
    }
    let mut prime_counters = vec![(2i, 0i)];
    let mut current_num = 3i;
    let mut sum = 2i;
    while current_num < limit {
        let mut seen_divisor = false;
        for pc in prime_counters.iter_mut() {
            let (prime, offset) = *pc;
            let new_offset = (offset+1) % prime;
            if new_offset == 0 {
                seen_divisor = true;
            }
            *pc = (prime, new_offset)
        }
        if !seen_divisor {
            prime_counters.push((current_num, 0));
            sum += current_num;
        }
        current_num += 1;
        println!("{}% done", 100*current_num/limit);
    }
    return sum
}

#[allow(dead_code)]
fn sum_of_primes_below4(limit: int) -> int {
    if limit <= 2 {
        return 0;
    }
    if limit <= 3 {
        return 2;
    }
    if limit <= 5 {
        return 5;
    }
    let mut prime_counters = vec![(2i, 1i), (3i, 1i)];
    let mut current_num = 5i;
    let mut sum = 5i;
    while current_num < limit {

        let mut seen_divisor = false;
        for pc in prime_counters.iter_mut() {
            let (prime, offset) = *pc;
            let new_offset = (offset+4) % prime;
            if new_offset == 0 {
                seen_divisor = true;
            }
            *pc = (prime, new_offset)
        }
        if !seen_divisor {
            prime_counters.push((current_num, 0));
            sum += current_num;
        }

        current_num += 2;
        if current_num < limit {
            seen_divisor = false;
            for pc in prime_counters.iter_mut() {
                let (prime, offset) = *pc;
                let new_offset = (offset+2) % prime;
                if new_offset == 0 {
                    seen_divisor = true;
                }
                *pc = (prime, new_offset)
            }
            if !seen_divisor {
{'fraction_non_alphanumeric': 0.13144639002158792, 'fraction_numerical': 0.024946030223075077, 'mean_word_length': 1.5501529051987768, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6363907', 'n_tokens_mistral': 3101, 'n_tokens_neox': 2875, 'n_words': 793}