Fairshare between two and more: Difference between revisions

Added XPL0 example.
(Added Arturo implementation)
(Added XPL0 example.)
Line 2,187:
With 50000 people: 1
With 50001 people: only 50000 have a turn
</pre>
 
=={{header|XPL0}}==
<lang XPL0>proc Fair(Base); \Show first 25 terms of fairshare sequence
int Base, Count, Sum, N, Q;
[RlOut(0, float(Base)); Text(0, ": ");
for Count:= 0 to 25-1 do
[Sum:= 0; N:= Count;
while N do
[Q:= N/Base;
Sum:= Sum + rem(0);
N:= Q;
];
RlOut(0, float(rem(Sum/Base)));
];
CrLf(0);
];
 
[Format(3,0);
Fair(2); Fair(3); Fair(5); Fair(11);
]</lang>
 
{{out}}
<pre>
2: 0 1 1 0 1 0 0 1 1 0 0 1 0 1 1 0 1 0 0 1 0 1 1 0 0
3: 0 1 2 1 2 0 2 0 1 1 2 0 2 0 1 0 1 2 2 0 1 0 1 2 1
5: 0 1 2 3 4 1 2 3 4 0 2 3 4 0 1 3 4 0 1 2 4 0 1 2 3
11: 0 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 0 2 3 4
</pre>
 
772

edits