From ef22265913e737923abba2435e399a85f8a3933e Mon Sep 17 00:00:00 2001 From: water Date: Tue, 25 Jun 2024 13:34:24 +0800 Subject: [PATCH] feat: update sum to cube --- packages/math/src/armstrong_number.cairo | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/math/src/armstrong_number.cairo b/packages/math/src/armstrong_number.cairo index 9d25314e..e08b4d8f 100644 --- a/packages/math/src/armstrong_number.cairo +++ b/packages/math/src/armstrong_number.cairo @@ -7,19 +7,19 @@ use super::{count_digits_of_base, pow}; /// # Returns /// * `bool` - A boolean value indicating is Armstrong Number. pub fn is_armstrong_number(mut num: u128) -> bool { - let mut original_num = num; + let mut remainder_num = num; let digits = count_digits_of_base(num, 10); loop { if num == 0 { - break original_num == 0; + break remainder_num == 0; } let lastDigit = num % 10; - let sum = pow(lastDigit, digits); - num = num / 10; - if sum > original_num { + let cube = pow(lastDigit, digits); + if cube > remainder_num { break false; } - original_num = original_num - sum; + remainder_num = remainder_num - cube; + num = num / 10; } }