exercism/rust/grains/src/lib.rs
2017-04-27 20:59:31 -04:00

16 lines
285 B
Rust

pub fn square(s: u32) -> u64 {
if (s > 0) && (s < 65){
return 2u64.pow(s-1);
}
else{
panic!("Square must be between 1 and 64");
}
}
pub fn total() -> u64 {
let mut sum: u64 = 0;
for i in 1..65{
sum += square(i);
}
return sum;
}