Minimization of while loop in Armstrong Numbers (#9976)

* Minimization of while loop in Armstrong Numbers

The while loop is removed and simple length calculation is used so the task of minimization of while loop is achieved

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Dwarkadhish Kamthane 2023-10-16 13:51:03 +05:30 committed by GitHub
parent 96f81770d7
commit 69707bf693
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -29,9 +29,7 @@ def armstrong_number(n: int) -> bool:
number_of_digits = 0
temp = n
# Calculation of digits of the number
while temp > 0:
number_of_digits += 1
temp //= 10
number_of_digits = len(str(n))
# Dividing number into separate digits and find Armstrong number
temp = n
while temp > 0: