Fairshare between two and more: Difference between revisions
Content added Content deleted
m (sp.) |
Thundergnat (talk | contribs) (→{{header|Perl 6}}: Add a Perl 6 example) |
||
Line 32: | Line 32: | ||
* [https://oeis.org/A010060 A010060], [https://oeis.org/A053838 A053838], [https://oeis.org/A053840 A053840], [https://oeis.org/A053842 A053842]: The On-Line Encyclopedia of Integer Sequences® (OEIS®) |
* [https://oeis.org/A010060 A010060], [https://oeis.org/A053838 A053838], [https://oeis.org/A053840 A053840], [https://oeis.org/A053842 A053842]: The On-Line Encyclopedia of Integer Sequences® (OEIS®) |
||
=={{header|Perl 6}}== |
|||
{{works with|Rakudo|2020.01}} |
|||
<lang perl6>my $terms = 25; |
|||
for <2 3 5 7 11> -> \b { |
|||
put b.fmt('%2d'), ': ', |
|||
((^∞).map({.base(b).comb».parse-base(b).sum % b}))[^$terms]».fmt('%2d').join: ', ' |
|||
}</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 |
|||
7: 0, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 0, 2, 3, 4, 5, 6, 0, 1, 3, 4, 5, 6 |
|||
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|Python}}== |
=={{header|Python}}== |