use std::io; use std::io::Stdin; // コピペ struct Input { n: i32, } fn main() { let mut stdin = io::stdin(); let input = read_input(&mut stdin); let result = (1..input.n + 1).fold(0, |a, b| a + b); println!("{}", result) } // コピペ fn read_input(stdin: &mut Stdin) -> Input { let mut s = String::new(); stdin.read_line(&mut s).expect("can't read input."); let n = s.trim_end().parse::().expect("can't convert to integer"); Input { n } }