InferenceAI

Enter at least two characters to search.

Start free

Narcissistic Number

easyMath15 min10 XP

A number with dd digits is narcissistic (an Armstrong number) when it equals the sum of each digit raised to the power dd. For example 153=13+53+33153 = 1^3 + 5^3 + 3^3.

Return True if n is narcissistic.

Constraints

  • 0≤n≤1090 \le n \le 10^9

Examples

EXAMPLE WALKTHROUGHclassic example

A guided view of the published example, not a trace of your code.

INPUT[153]
TASKnarcissistic_number()
EXPECTED OUTPUTtrue

Start with the input values shown in this example.

Example 1 of 3

Input: n = 153

Output: true

Explanation: classic example

Input: n = 123

Output: false

Explanation: not narcissistic

Input: n = 0

Output: true

Explanation: zero

Hint 1

Convert to a string to get the digits and their count.

Topics

DSAMathPython