Disarium numbers: Difference between revisions

Add Draco
(Add BCPL)
(Add Draco)
Line 1,001:
lIx # running iteration macro the first time
</syntaxhighlight>
 
=={{header|Draco}}==
<syntaxhighlight lang="draco">proc nonrec pow(byte base, exp) word:
word p;
p := 1;
while exp>0 do
p := p*base;
exp := exp-1
od;
p
corp
 
proc nonrec disarium(word n) bool:
[5]byte digits;
short i, len;
word input_n, dps;
dps := 0;
i := 0;
input_n := n;
while n > 0 do
digits[i] := n % 10;
n := n / 10;
i := i + 1
od;
len := i;
for i from 0 upto len-1 do
dps := dps + pow(digits[i], len-i)
od;
dps = input_n
corp
 
proc nonrec main() void:
word n;
for n from 0 upto 2500 do
if disarium(n) then writeln(n:5) fi
od
corp</syntaxhighlight>
{{out}}
<pre> 0
1
2
3
4
5
6
7
8
9
89
135
175
518
598
1306
1676
2427</pre>
 
=={{header|Factor}}==
2,114

edits