Jump to content

Munchausen numbers: Difference between revisions

Added XPL0 example.
(Added XPL0 example.)
Line 2,892:
<pre>
The Munchausen numbers <= 5000 are:
1
3435
</pre>
 
=={{header|XPL0}}==
The digits 6, 7, 8 and 9 can't occur because 6^6 = 46656, which is beyond 5000.
<lang XPL0>int Pow, A, B, C, D, N;
[Pow:= [0, 1, 4, 27, 256, 3125];
for A:= 0 to 5 do
for B:= 0 to 5 do
for C:= 0 to 5 do
for D:= 0 to 5 do
[N:= A*1000 + B*100 + C*10 + D;
if Pow(A) + Pow(B) + Pow(C) + Pow(D) = N then
if N>=1 & N<= 5000 then
[IntOut(0, N); CrLf(0)];
];
]</lang>
 
{{out}}
<pre>
1
3435
772

edits

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