Factorions: Difference between revisions

Add lang example
(Added uBasic/4tH version)
(Add lang example)
Line 904:
 
</syntaxhighlight>
 
=={{header|Lang}}==
{{trans|Python}}
<syntaxhighlight lang="lang">
# Enabling raw variable names boosts the performance massivly [DO NOT RUN WITHOUT enabling raw variable names]
lang.rawVariableNames = 1
 
# Cache factorials from 0 to 11
&fact = fn.listOf(1)
$n = 1
while($n < 12) {
&fact += &fact[-|$n] * $n
$n += 1
}
 
$b = 9
while($b <= 12) {
fn.printf(The factorions for base %d are:%n, $b)
$i = 1
while($i < 1500000) {
$sum = 0
$j = $i
while($j > 0) {
$d $= $j % $b
$sum += &fact[$d]
$j //= $b
}
if($sum == $i) {
fn.print($i\s)
}
$i += 1
}
fn.println(\n)
$b += 1
}
</syntaxhighlight>
{{out}}
<pre>
The factorions for base 9 are:
1 2 41282
 
The factorions for base 10 are:
1 2 145 40585
 
The factorions for base 11 are:
1 2 26 48 40472
 
The factorions for base 12 are:
1 2
 
</pre>
 
=={{header|Mathematica}} / {{header|Wolfram Language}}==
168

edits