Narcissistic decimal number: Difference between revisions
Content deleted Content added
m →ES6 |
m →JS ES6: Updated the preamble |
||
Line 1,543: | Line 1,543: | ||
As summing the nth power of the digits is unaffected by digit order, we can reduce the search space by filtering digit combinations of given length and arbitrary order, rather than filtering a full integer sequence. |
As summing the nth power of the digits is unaffected by digit order, we can reduce the search space by filtering digit combinations of given length and arbitrary order, rather than filtering a full integer sequence. |
||
In this way we can find the 25th narcissistic number after ''' |
In this way we can find the 25th narcissistic number after '''length(concatMap(digitPowerSums, enumFromTo(0, 7))) === 19447''' tests – an improvement on the exhaustive trawl through '''9926315''' integers. |
||
(Generating the unordered digit combinations directly as power sums allows faster testing later, and needs less space) |
(Generating the unordered digit combinations directly as power sums allows faster testing later, and needs less space) |