grains is should panic
This commit is contained in:
parent
34eb2e1c4e
commit
9ea786eda5
1 changed files with 4 additions and 1 deletions
|
|
@ -1,7 +1,10 @@
|
||||||
pub fn square(s: u32) -> u64 {
|
pub fn square(s: u32) -> u64 {
|
||||||
|
if s == 0 || s > 64 {
|
||||||
|
panic!("Square must be between 1 and 64");
|
||||||
|
}
|
||||||
2_u64.pow(s - 1)
|
2_u64.pow(s - 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn total() -> u64 {
|
pub fn total() -> u64 {
|
||||||
(1..=64).map(|x| square(x)).sum()
|
(1..=64).map(square).sum()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue