Narcissistic Numbers

I heard about these on BBC Radio 4 More or Less and they just intrigued me, perhaps in part because they have no know application! In the past similar obsessions have appeared with the calculation of PI and right back to my childhood calculating powers of 2 on a BBC Micro! The full definition, as for everything, is on Wikipedia but in short a narcissistic number is one where the sum of the digits raised to the power of the number of digits equals the number itself. For example, 153 = 1^3 + 5^3 + 3^3. Here's some quick and dirty Perl code to calculate them: use strict; use warnings; for (my $i = 0; $i < 10000; $i++) { my $pwr = length($i); my $total = 0; for (my $j =…
Read More