Narcissistic decimal number: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: changed whitespace and comments, changed comments in the output section.) |
(GP) |
||
Line 1,296: | Line 1,296: | ||
548834, 1741725, 4210818, 9800817, 9926315] ok |
548834, 1741725, 4210818, 9800817, 9926315] ok |
||
</pre> |
</pre> |
||
=={{header|PARI/GP}}== |
|||
Naive code, could be improved by splitting the digits in half and meeting in the middle. |
|||
<lang parigp>isNarcissistic(n)=my(v=digits(n)); sum(i=1, #v, v[i]^#v)==n |
|||
v=List();for(n=1,1e9,if(isNarcissistic(n),listput(v,n);if(#v>24, return(Vec(v)))))</lang> |
|||
{{out}} |
|||
<pre>%1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 153, 370, 371, 407, 1634, 8208, 9474, 54748, 92727, 93084, 548834, 1741725, 4210818, 9800817, 9926315, 24678050]</pre> |
|||
=={{header|Pascal}}== |
=={{header|Pascal}}== |