Jump to content

Narcissistic decimal number: Difference between revisions

(Dialects of BASIC moved to the BASIC section.)
Line 727:
 
=={{header|BASIC}}==
==={{header|Chipmunk Basic}}===
{{trans|Go}}
Differently from the original version, no data structure for the result is used - why should it be?
<syntaxhighlight lang="basic">
100 rem Narcissistic decimal number
110 n = 25
120 dim power(9)
130 for i = 0 to 9
140 power(i) = i
150 next i
160 limit = 10
170 cnt = 0 : x = 0
180 while cnt < n
190 if x >= limit then
200 for i = 0 to 9
210 power(i) = power(i)*i
220 next i
230 limit = limit*10
240 endif
250 sum = 0 : xx = x
260 while xx > 0
270 sum = sum+power(xx mod 10)
280 xx = int(xx/10)
290 wend
300 if sum = x then print x; : cnt = cnt+1
310 x = x+1
320 wend
330 print
340 end
</syntaxhighlight>
{{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>
 
==={{header|FreeBASIC}}===
====Simple Version====
512

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.