maths.special_numbers.armstrong_numbers¶
An Armstrong number is equal to the sum of its own digits each raised to the power of the number of digits.
For example, 370 is an Armstrong number because 3*3*3 + 7*7*7 + 0*0*0 = 370.
Armstrong numbers are also called Narcissistic numbers and Pluperfect numbers.
On-Line Encyclopedia of Integer Sequences entry: https://oeis.org/A005188
Attributes¶
Functions¶
|
Return True if n is an Armstrong number or False if it is not. |
|
Request that user input an integer and tell them if it is Armstrong number. |
|
Return True if n is a narcissistic number or False if it is not. |
|
Return True if n is a pluperfect number or False if it is not |
Module Contents¶
- maths.special_numbers.armstrong_numbers.armstrong_number(n: int) bool ¶
Return True if n is an Armstrong number or False if it is not.
>>> all(armstrong_number(n) for n in PASSING) True >>> any(armstrong_number(n) for n in FAILING) False
- maths.special_numbers.armstrong_numbers.main()¶
Request that user input an integer and tell them if it is Armstrong number.
- maths.special_numbers.armstrong_numbers.narcissistic_number(n: int) bool ¶
Return True if n is a narcissistic number or False if it is not.
>>> all(armstrong_number(n) for n in PASSING) True >>> any(armstrong_number(n) for n in FAILING) False
- maths.special_numbers.armstrong_numbers.pluperfect_number(n: int) bool ¶
Return True if n is a pluperfect number or False if it is not
>>> all(armstrong_number(n) for n in PASSING) True >>> any(armstrong_number(n) for n in FAILING) False
- maths.special_numbers.armstrong_numbers.FAILING: tuple¶
- maths.special_numbers.armstrong_numbers.PASSING = (1, 153, 370, 371, 1634, 24678051, 115132219018763992565095597973971522401)¶