Munchausen numbers: Difference between revisions

Add Draco
(Add ABC)
(Add Draco)
Line 1,089:
=={{header|Delphi}}==
See [https://rosettacode.org/wiki/Munchausen_numbers#Pascal Pascal].
 
=={{header|Draco}}==
<syntaxhighlight lang="draco">proc munchausen(word n) bool:
/* d^d for d>6 does not fit in a 16-bit word,
* it follows that any 16-bit integer containing
* a digit d>6 is not a Munchausen number */
[7]word dpow = (1, 1, 4, 27, 256, 3125, 46656);
word m, d, sum;
 
m := n;
sum := 0;
while
d := m % 10;
m>0 and d<=6
do
m := m/10;
sum := sum + dpow[d]
od;
d<=6 and sum=n
corp;
 
proc main() void:
word n;
for n from 1 upto 5000 do
if munchausen(n) then
writeln(n)
fi
od
corp</syntaxhighlight>
{{out}}
<pre>1
3435</pre>
 
=={{header|EasyLang}}==
2,114

edits