prevent infinite loop

This commit is contained in:
Julian Orth
2014-06-05 22:35:32 +02:00
parent f0d121c8cc
commit 7ae05b9935
2 changed files with 4 additions and 1 deletions
+3
View File
@@ -27,6 +27,9 @@ static NAME: &'static str = "factor";
fn factor(mut num: u64) -> Vec<u64> {
let mut ret = Vec::new();
if num < 2 {
return ret;
}
while num % 2 == 0 {
num /= 2;
ret.push(2);