use rayon::prelude::*;

fn main() {
    println!("{}", sum_of_squares(&vec![11, 22, 3, 4, 5, 6, 7]));
    println!("{}", fib_iterative(40));
    println!("{}", fib_recursive(40));
}

fn sum_of_squares(input: &[i32]) -> i32 {
    input.par_iter() // <-- just change that!
         .map(|&i| i * i)
         .sum()
}

fn fib_iterative(n: u128) -> u128 {
    let mut a = 0;
    let mut b = 1;
    for _ in 0..n {
        let c = a + b;
        a = b;
        b = c;
    }
    a
}

fn fib_recursive(n: u128) -> u128 {
    if n < 2 {
        return n;
    }

    fib_recursive(n - 1) + fib_recursive(n - 2)
}
