<commit_before>extern crate test;
use std::cmp::min;
pub fn exe(max:u32)->u32{
    (2..max+1).rev().fold(1,|sum,x|sum*x/greatest_common_divisor(sum,x))
}

fn greatest_common_divisor(a:u32,b:u32)->u32{
    (2..min(a,b)+1).rev().filter(|x|b%x==0&&a%x==0).take(1).next().unwrap_or(1)
}

#[cfg(test)]
mod tests{
    use super::test::Bencher;

    #[test]
    fn test_greatest_common_divisor1(){
        assert_eq!(super::greatest_common_divisor(4*3,4*35),4);
    }
    #[test]
    fn test_greatest_common_divisor2(){
        assert_eq!(super::greatest_common_divisor(1024,81),1);
    }
    #[test]
    fn test_greatest_common_divisor3(){
        assert_eq!(super::greatest_common_divisor(100*3,100*2),100);
    }

    #[test]
    fn test_exe(){
        assert_eq!(super::exe(10),2520);
    }
<commit_msg>ユークリッドの互除法を利用<commit_after>extern crate test;
use std::cmp::*;
pub fn exe(max:u32)->u32{
    (2..max+1).rev().fold(1,|sum,x|sum*x/greatest_common_divisor(sum,x))
}

fn greatest_common_divisor(a:u32,b:u32)->u32{
    let big = max(a,b);
    let small = min(a,b);
    if small ==0 {big} else {greatest_common_divisor(small,big%small)}
}

#[cfg(test)]
mod tests{
    use super::test::Bencher;

    #[test]
    fn test_greatest_common_divisor1(){
        assert_eq!(super::greatest_common_divisor(4*3,4*35),4);
    }
    #[test]
    fn test_greatest_common_divisor2(){
        assert_eq!(super::greatest_common_divisor(1024,81),1);
    }
    #[test]
    fn test_greatest_common_divisor3(){
        assert_eq!(super::greatest_common_divisor(100*3,100*2),100);
    }

    #[test]
    fn test_exe(){
        assert_eq!(super::exe(10),2520);
    }

{'fraction_non_alphanumeric': 0.18791946308724833, 'fraction_numerical': 0.06040268456375839, 'mean_word_length': 4.23961661341853, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '50996', 'n_tokens_mistral': 760, 'n_tokens_neox': 694, 'n_words': 77}