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.449999999999999
2.592857142857143
2.592857142857141
2.717857142857143
2.717857142857141
2.828968253968254
2.828968253968252
2.928968253968254
2.928968253968252
3.019877344877345
3.019877344877342
3.103210678210678
3.103210678210675
3.180133755133755
3.180133755133751
3.251562326562326
3.251562326562322
3.318228993228993
3.318228993228988
3.380728993228993
3.380728993228988
3.439552522640758
3.439552522640752
3.495108078196314
3.495108078196307
3.547739657143682
3.547739657143675
3.597739657143682
3.597739657143675
 
The nth index of the first harmonic number that exceeds the nth integer:
357

edits