From b4dd12104fac6be7adf33a74d8d53d482c92cacc Mon Sep 17 00:00:00 2001 From: Roman Gafiyatullin Date: Fri, 2 Oct 2015 20:30:35 +0300 Subject: [PATCH] factor: panic running againts power of two. No further calculations required in case 'num' is already 1. --- src/factor/factor.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/factor/factor.rs b/src/factor/factor.rs index 8f78e8739..b037be020 100644 --- a/src/factor/factor.rs +++ b/src/factor/factor.rs @@ -94,6 +94,9 @@ fn table_division(mut num: u64, factors: &mut Vec) { num /= 2; factors.push(2); } + if num == 1 { + return; + } if is_prime(num) { factors.push(num); return;