Josephus problem: Difference between revisions
Content added Content deleted
(→{{header|Palo Alto Tiny BASIC}}: Added a solution.) |
imported>Maxima enthusiast No edit summary |
||
Line 3,123: | Line 3,123: | ||
end |
end |
||
</syntaxhighlight> |
</syntaxhighlight> |
||
=={{header|Maxima}}== |
|||
<syntaxhighlight lang="maxima"> |
|||
josephus_list(n,k):=(result:[],pos:1,ref:makelist(i,i,n),while ref#[] do (pos:mod(pos+k-2,length(ref))+1,push(ref[pos],result),ref:delete(ref[pos],ref)), |
|||
reverse(result)); |
|||
/* Example */ |
|||
/* last_survivor:last(josephus_list(41,3)); |
|||
31 |
|||
*/ |
|||
</syntaxhighlight> |
|||
=={{header|Modula-2}}== |
=={{header|Modula-2}}== |