- May 8, 2005
- 415
- 0
- 76
so i'm trying to create a program in drScheme that can basically add the reciprocals of the first n natural numbers. so if n=3 then it should return 1/1+1/2+1/3=1.833333.
now i'm supposed to do this program iteratively and i've figured out how to do that but it runs VERY slow. when n=10000000, it takes a couple of minutes. it should run in under 10 seconds.
a hint that was given was: 1/i is approximately the integral of 1/x from i-1/2 to i+1/2.
but i dont really know how to apply that
can anyone help?
now i'm supposed to do this program iteratively and i've figured out how to do that but it runs VERY slow. when n=10000000, it takes a couple of minutes. it should run in under 10 seconds.
a hint that was given was: 1/i is approximately the integral of 1/x from i-1/2 to i+1/2.
but i dont really know how to apply that
can anyone help?