Fairshare between two and more: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: added wording to the REXX section header.) |
Alextretyak (talk | contribs) (Added 11l) |
||
Line 37: | Line 37: | ||
:* [https://oeis.org/A010060 A010060], [https://oeis.org/A053838 A053838], [https://oeis.org/A053840 A053840]: The On-Line Encyclopedia of Integer Sequences® (OEIS®) |
:* [https://oeis.org/A010060 A010060], [https://oeis.org/A053838 A053838], [https://oeis.org/A053840 A053840]: The On-Line Encyclopedia of Integer Sequences® (OEIS®) |
||
<br><br> |
<br><br> |
||
=={{header|11l}}== |
|||
{{trans|Python}} |
|||
<lang 11l>F _basechange_int(=num, b) |
|||
‘ |
|||
Return list of ints representing positive num in base b |
|||
’ |
|||
I num == 0 |
|||
R [0] |
|||
[Int] result |
|||
L num != 0 |
|||
(num, V d) = divmod(num, b) |
|||
result.append(d) |
|||
R reversed(result) |
|||
F fairshare(b, n) |
|||
[Int] r |
|||
L(i) 0.. |
|||
r [+]= sum(_basechange_int(i, b)) % b |
|||
I r.len == n |
|||
L.break |
|||
R r |
|||
L(b) (2, 3, 5, 11) |
|||
print(‘#2’.format(b)‘: ’String(fairshare(b, 25))[1 .< (len)-1])</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> |
|||
=={{header|AppleScript}}== |
=={{header|AppleScript}}== |
||
Line 321: | Line 355: | ||
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] |
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> |
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|C}}== |
=={{header|C}}== |