Josephus problem: Difference between revisions

Content added Content deleted
m (J: Add spaces around the subtraction to help mislead eyes slightly less when they have been [mis-]trained by some OO syntax)
m (J: actually that was negation, not subtraction - so let's go a bit further in the classic notation direction)
Line 1,031: Line 1,031:
=== Explicit version 2 ===
=== Explicit version 2 ===
<lang J>
<lang J>
Josephus2 =: 4 : '(|x&+)/i. - >:y' NB. this is a direct translation of the algo from C code above.
Josephus2 =: 4 : '(| x&+)/i. - 1+y' NB. this is a direct translation of the algo from C code above.


3 Josephus2 41
3 Josephus2 41