Solve hanging lantern problem: Difference between revisions
→{{header|APL}}: Credit source of formula, add more examples, use iota.
(→{{header|APL}}: Add implementation.) |
(→{{header|APL}}: Credit source of formula, add more examples, use iota.) |
||
Line 47:
=={{header|APL}}==
{{trans|Pascal}
<lang apl>lanterns ← { (!+/⍵) ÷ ×/!⍵ }</lang>
{{Out}}
Line 53 ⟶ 54:
lanterns 1 3 3
140
lanterns 1 2 3 4▼
▲12600</pre>
Of course, for the simple sequences from 1, we can use iota to generate them instead of typing them out:
<pre>
lanterns ⍳4 ⍝ same as lanterns 1 2 3 4
12600
37837800</pre>
=={{header|BASIC}}==
|