pub fn square(s: u32) -> u64 { assert!(s > 0 && s < 65,"Square must be between 1 and 64"); 2_u64.pow(s-1) } /// This version uses the already defined `square(s)` function. /// /// There is also a faster way to compute this according to /// [Wolfram|Alpha](https://www.wolframalpha.com/input/?i=sum_0%5En+2%5En) /// /// 2_u64.pow(65) - 1 == 18_446_744_073_709_551_615 /// /// this solution however doesn't work because /// /// 2_u64.pow(65) == 18_446_744_073_709_551_616 /// /// which overflows since /// /// std::u64::MAX == 18_446_744_073_709_551_615 /// pub fn total() -> u64 { (1..65).map(square).sum() // std::u64::MAX }