Fairshare between two and more: Difference between revisions

Add Draco
(Add Cowgol)
(Add Draco)
Line 732:
With 50000 people: 1
With 50001 people: Only 50000 have a turn</pre>
 
=={{header|Draco}}==
<syntaxhighlight lang="draco">proc fairshare(word n, base) word:
word result;
result := 0;
while n>0 do
result := result + n % base;
n := n / base
od;
result % base
corp
 
proc main() void:
[4]word bases = (2,3,5,11);
word b, n;
for b from 0 upto 3 do
write(bases[b]:2, ':');
for n from 0 upto 24 do
write(fairshare(n, bases[b]):3)
od;
writeln()
od
corp</syntaxhighlight>
{{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>
 
=={{header|Factor}}==
Line 752 ⟶ 780:
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>
 
 
=={{header|FreeBASIC}}==
2,124

edits