Fairshare between two and more: Difference between revisions

→‎{{header|Ruby}}: added another translation
(→‎{{header|Ruby}}: added another translation)
Line 2,359:
With 50000 people: 1
With 50001 people: Only 50000 have a turn</pre>
{{trans|Sidef}}
<syntaxhighlight lang="ruby">
def fairshare(base, upto) = (0...upto).map{|n| n.digits(base).sum % base}
 
upto = 25
[2, 3, 5, 11].each{|b| puts"#{'%2d' % b}: " + " %2d"*upto % fairshare(b, upto)}
</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|Rust}}==
1,149

edits