Factorions: Difference between revisions
Content added Content deleted
(adding lambdatalk) |
|||
Line 861: | Line 861: | ||
Factorians for base 12: [1, 2] |
Factorians for base 12: [1, 2] |
||
</pre> |
</pre> |
||
=={{header|Lambdatalk}}== |
|||
<syntaxhighlight lang="scheme"> |
|||
{def facts |
|||
{S.first |
|||
{S.map {{lambda {:a :i} |
|||
{A.addlast! {* {A.get {- :i 1} :a} :i} :a} |
|||
} {A.new 1}} |
|||
{S.serie 1 11}}}} |
|||
-> facts |
|||
{def sumfacts |
|||
{def sumfacts.r |
|||
{lambda {:base :sum :i} |
|||
{if {> :i 0} |
|||
then {sumfacts.r :base |
|||
{+ :sum {A.get {% :i :base} {facts}}} |
|||
{floor {/ :i :base}}} |
|||
else :sum }}} |
|||
{lambda {:base :n} |
|||
{sumfacts.r :base 0 :n}}} |
|||
-> sumfacts |
|||
{def show |
|||
{lambda {:base} |
|||
{S.replace \s by space in |
|||
{S.map {{lambda {:base :i} |
|||
{if {= {sumfacts :base :i} :i} then :i else} |
|||
} :base} |
|||
{S.serie 1 50000}}}}} |
|||
-> show |
|||
{S.map {lambda {:base} |
|||
{div}factorions for base :base: {show :base}} |
|||
9 10 11 12} |
|||
-> |
|||
factorions for base 9: 1 2 41282 |
|||
factorions for base 10: 1 2 145 40585 |
|||
factorions for base 11: 1 2 26 48 40472 |
|||
factorions for base 12: 1 2 |
|||
</syntaxhighlight> |
|||
=={{header|Mathematica}} / {{header|Wolfram Language}}== |
=={{header|Mathematica}} / {{header|Wolfram Language}}== |