keep-starknet-strange / alexandria

Community maintained Cairo libraries and set of well maintained, optimised and secure components.
MIT License
231 stars 100 forks source link

feat: update sum to cube #318

Closed suiwater closed 4 weeks ago

suiwater commented 3 months ago
pub fn is_armstrong_number(mut num: u128) -> bool {
    let original_num = num;
    let mut sum = 0;
    let digits = count_digits_of_base(num, 10);
    loop {
        if num == 0 {
            break original_num == sum;
        }

        let lastDigit = num % 10;
        let sum = sum + pow(lastDigit, digits);
        num = num / 10;
        if sum > original_num {
            break false;
        }
    }
}

The original code may have been like this, so using variable sum is not suitable now

github-actions[bot] commented 2 months ago

There hasn't been any activity on this pull request recently, and in order to prioritize active work, it has been marked as stale. This PR will be closed and locked in 7 days if no further activity occurs. Thank you for your contributions!

github-actions[bot] commented 1 month ago

There hasn't been any activity on this pull request recently, and in order to prioritize active work, it has been marked as stale. This PR will be closed and locked in 7 days if no further activity occurs. Thank you for your contributions!