Munchausen numbers: Difference between revisions

Content added Content deleted
(Added solution for Action!)
(Add CLU)
Line 860: Line 860:
(1 3435)
(1 3435)
</pre>
</pre>

=={{header|CLU}}==
<lang clu>digits = iter (n: int) yields (int)
while n>0 do
yield(n//10)
n := n/10
end
end digits

munchausen = proc (n: int) returns (bool)
k: int := 0
for d: int in digits(n) do
% Note: 0^0 is to be regarded as 0
if d~=0 then k := k + d ** d end
end
return(n = k)
end munchausen

start_up = proc ()
po: stream := stream$primary_output()
for i: int in int$from_to(1,5000) do
if munchausen(i) then stream$putl(po, int$unparse(i)) end
end
end start_up</lang>
{{out}}
<pre>1
3435</pre>


=={{header|Common Lisp}}==
=={{header|Common Lisp}}==