Fusc sequence: Difference between revisions
Added Arturo implementation
ReeceGoding (talk | contribs) (→{{header|R}}: Improved speed and readability of which() calls.) |
Drkameleon (talk | contribs) (Added Arturo implementation) |
||
Line 554:
(1173, 108)
(35499, 1076)</pre>
=={{header|Arturo}}==
{{trans|Nim}}
<lang rebol>fusc: function [n][
if? or? n=0 n=1 -> n
else [
if? 0=n%2 -> fusc n/2
else -> (fusc (n-1)/2) + fusc (n+1)/2
]
]
print "The first 61 Fusc numbers:"
print map 0..61 => fusc
print "\nThe Fusc numbers whose lengths are greater than those of previous Fusc numbers:"
print " n fusc(n)"
print "--------- ---------"
maxLength: 0
loop 0..40000 'i [
f: fusc i
l: size to :string f
if l > maxLength [
maxLength: l
print [
pad to :string i 9
pad to :string f 9
]
]
]</lang>
{{out}}
<pre>The first 61 Fusc numbers:
0 1 1 2 1 3 2 3 1 4 3 5 2 5 3 4 1 5 4 7 3 8 5 7 2 7 5 8 3 7 4 5 1 6 5 9 4 11 7 10 3 11 8 13 5 12 7 9 2 9 7 12 5 13 8 11 3 10 7 11 4 9
The Fusc numbers whose lengths are greater than those of previous Fusc numbers:
n fusc(n)
--------- ---------
0 0
37 11
1173 108
35499 1076</pre>
=={{header|AWK}}==
|