Josephus problem: Difference between revisions

m
(Added solution for EDSAC)
 
(3 intermediate revisions by 3 users not shown)
Line 2,581:
[[File:Fōrmulæ - Josephus problem 02.png]]
 
[[File:Fōrmulæ - Josephus problem 03a03.png]]
 
'''Case 2.''' 41 prisoners, killing every 3:
Line 2,599:
[[File:Fōrmulæ - Josephus problem 08.png]]
 
[[File:Fōrmulæ - Josephus problem 09a09.png]]
 
'''Drawing history'''
Line 3,685:
 
===iterative===
ALGOL 68, ANSI Standard BASIC, AppleScript[1,3(!!)], BASIC(*11), Batch File, C (but not ULL), Common Lisp[1], Craft Basic, Easylang, EDSAC (allegedly), Factor, Forth, FreeBASIC, FTCBASIC, Modula-2, Python[2], R, Racket, Ring, SequenceL, ZX Spectrum Basic<br>
Method: iterative mod maths madness - but hey, it will be extremely fast. Unlike recursive, it can also deliver >1 survivor, one at a time.
<!--<syntaxhighlight lang="phix">-->
Line 4,854:
=={{header|Wren}}==
{{trans|Kotlin}}
<syntaxhighlight lang="ecmascriptwren">var josephus = Fn.new { |n, k, m|
if (k <= 0 || m <= 0 || n <= k || n <= m) Fiber.abort("One or more parameters are invalid.")
var killed = []
2,120

edits