Factorions: Difference between revisions

no edit summary
(Added Arturo implementation)
No edit summary
Line 1,624:
The factorions for base 12 are:
1 2</pre>
 
=={{header|Vlang}}==
{{trans|Go}}
<lang vlang>import strconv
 
fn main() {
// cache factorials from 0 to 11
mut fact := [12]u64{}
fact[0] = 1
for n := u64(1); n < 12; n++ {
fact[n] = fact[n-1] * n
}
for b := 9; b <= 12; b++ {
println("The factorions for base $b are:")
for i := u64(1); i < 1500000; i++ {
digits := strconv.format_uint(i, b)
mut sum := u64(0)
for digit in digits {
if digit < `a` {
sum += fact[digit-`0`]
} else {
sum += fact[digit+10-`a`]
}
}
if sum == i {
print("$i ")
}
}
println("\n")
}
}</lang>
 
{{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|Wren}}==
338

edits