You Narcissist!

Find the sum of all the 4 digit numbers whose sum of fourth power of each digit of the number is equal to the number itself.


The answer is 19316.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

2 solutions

Bill Bell
Mar 3, 2015

Using the definition of the numbers given in the problem:

Brock Brown
Mar 3, 2015

This problem is asking for the sum of every 4 digit narcissistic number. My program iterates through every four digit number, checks if it's narcissistic, and if it is it adds it to the sum.

Python:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
def narcissist(n):
    total = 0
    s = str(n)
    for digit in s:
        total += int(digit)**len(s)
    return total == n
total = 0
for n in xrange(1000,10000):
    if narcissist(n):
        total += n
print "Answer:", total

Narcissistic numbers: http://en.wikipedia.org/wiki/Narcissistic_number

well done..

Vighnesh Raut - 6 years, 3 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...