Narcissistic decimal number: Difference between revisions

(→‎{{header|Julia}}: A new entry for Julia)
Line 1,004:
{{out}}
<pre>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 </pre>
 
{{works with|Java|1.8}}
<lang java8>public class NarcissticNumbers {
public static void main(String[] args) {
IntStream.iterate(0, n -> n + 1).limit(Integer.MAX_VALUE).boxed().forEach(i -> {
int length = i.toString().length();
int addedDigits = 0;
for (int count = 0; count < length; count++) {
int value = Integer.parseInt(String.valueOf(i.toString().charAt(count)));
addedDigits += Math.pow(value, length);
}
if (i == addedDigits) {
System.out.println(addedDigits + ", ");
}
});
}
}</lang>
{{out}}
<pre>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 24678050 24678051 88593477 </pre>
 
=={{header|JavaScript}}==