mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-23 21:11:08 +00:00
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:
parent
96f81770d7
commit
69707bf693
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue
Block a user