Solve hanging lantern problem: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 422: | Line 422: | ||
{{out}} |
{{out}} |
||
<pre>Same as FreeBASIC entry.</pre> |
<pre>Same as FreeBASIC entry.</pre> |
||
=={{header|FutureBasic}}== |
|||
<syntaxhighlight lang="futurebasic"> |
|||
_elements = 5 |
|||
local fn GetLantern( arr(_elements) as long ) as long |
|||
long i, res = 0 |
|||
for i = 1 to _elements |
|||
if arr(i) != 0 |
|||
arr(i) = arr(i) - 1 |
|||
res = res + fn GetLantern( arr(0) ) |
|||
arr(i) = arr(i) + 1 |
|||
end if |
|||
next |
|||
if res = 0 then res = 1 |
|||
end fn = res |
|||
long i, j, a(_elements) |
|||
for i = 1 to _elements |
|||
a(i) = i |
|||
print "["; |
|||
for j = 1 to i |
|||
if j == i then print a(j); else print a(j); ","; |
|||
next |
|||
print "] = "; fn GetLantern( a(0) ) |
|||
next |
|||
HandleEvents |
|||
</syntaxhighlight> |
|||
{{output}} |
|||
<pre> |
|||
[1] = 1 |
|||
[1,2] = 3 |
|||
[1,2,3] = 60 |
|||
[1,2,3,4] = 12600 |
|||
[1,2,3,4,5] = 37837800 |
|||
</pre> |
|||
=={{header|J}}== |
=={{header|J}}== |