diff --git a/src/main.rs b/src/main.rs index ff60b2c..2c8fd6a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,14 +27,11 @@ fn func(num: i32) -> String { let mut num = num; - while let Some(div) = stack.pop() { - while num/div.0 > 0 { - out.push(div.1); - num -= div.0; + while let Some((divisor, numeral)) = stack.pop() { + while num > divisor { + out.push(numeral); + num -= divisor; } - if num == 0 { - break - } } out.join("")