Harmonic series: Difference between revisions
Rounds each reciprocal before adding it to the sum for better accuracy.
(Rounds each reciprocal before adding it to the sum for better accuracy.) |
|||
Line 247:
1.0fx 1 2constant first-harmonic
: round 5 + 10 / ;
: next-harmonic ( h n -- h' n' )
1+ tuck [ 1.0fx 10 * ] literal swap / round + swap ;
: task1
Line 274 ⟶ 277:
2.083333333333333
2.283333333333333
2.450000000000000
2.592857142857143
2.717857142857143
2.828968253968254
2.928968253968254
3.019877344877345
3.103210678210678
3.180133755133755
3.251562326562326
3.318228993228993
3.380728993228993
3.439552522640758
3.495108078196314
3.547739657143682
3.597739657143682
The nth index of the first harmonic number that exceeds the nth integer:
|