Narcissistic decimal number: Difference between revisions
Content added Content deleted
m (→{{header|BQN}}: Fix evaluation line) |
(→{{header|BQN}}: Array-based method) |
||
Line 653: | Line 653: | ||
/IsNarc¨ ↕1e7</lang><lang bqn>⟨0 1 2 3 4 5 6 7 8 9 153 370 371 407 1634 8208 9474 54748 92727 93084 548834 1741725 4210818 9800817 9926315⟩</lang> |
/IsNarc¨ ↕1e7</lang><lang bqn>⟨0 1 2 3 4 5 6 7 8 9 153 370 371 407 1634 8208 9474 54748 92727 93084 548834 1741725 4210818 9800817 9926315⟩</lang> |
||
A much faster method is to generate a list of digit sums as addition tables (<code>+⌜</code>). A different list of digit sums is generated for each digit count, 0 to 7. To avoid leading 0s, 0 is removed from the first digit list with <code>(0=↕)↓¨</code>. Then all that needs to be done is to join the lists and return locations where the index (number) and value (digit power sum) are equal. |
|||
<lang bqn>/ ↕∘≠⊸= ∾ (⥊0+⌜´(0=↕)↓¨(<↕10)⋆⊢)¨↕8</lang> |
|||
=={{header|C}}== |
=={{header|C}}== |