Harmonic series: Difference between revisions

Content added Content deleted
(Added XPL0 example.)
(Added Arturo implementation)
Line 96: Line 96:
Position of the first harmonic number > 10: 12367
Position of the first harmonic number > 10: 12367
</pre>
</pre>
=={{header|Arturo}}==

<lang rebol>H: function [n][
sum map 1..n => reciprocal
]

firstAbove: function [lim][
i: 1
while ΓΈ [
if lim < to :floating H i ->
return i
i: i + 1
]
]

print "The first 20 harmonic numbers:"
print map 1..20 => H

print ""
loop 1..4 'l [
print ["Position of first term >" l ":" firstAbove l]
]</lang>

{{out}}

<pre>The first 20 harmonic numbers:
1/1 3/2 11/6 25/12 137/60 49/20 363/140 761/280 7129/2520 7381/2520 83711/27720 86021/27720 1145993/360360 1171733/360360 1195757/360360 2436559/720720 42142223/12252240 14274301/4084080 275295799/77597520 55835135/15519504

Position of first term > 1 : 2
Position of first term > 2 : 4
Position of first term > 3 : 11
Position of first term > 4 : 31</pre>

=={{header|AWK}}==
=={{header|AWK}}==
<lang AWK>
<lang AWK>
Line 154: Line 187:
The first harmonic number > 10 is 10.00004301 at position 12367
The first harmonic number > 10 is 10.00004301 at position 12367
</pre>
</pre>



=={{header|BASIC}}==
=={{header|BASIC}}==