Compute the   nth   term of a series,   i.e. the sum of the   n   first terms of the corresponding sequence.

Informally this value, or its limit when   n   tends to infinity, is also called the sum of the series, thus the title of this task.

For this task, use:

 




S

n


=

∑

k
=
1


n




1

k

2






{\displaystyle S_{n}=\sum _{k=1}^{n}{\frac {1}{k^{2}}}}




 and compute   




S

1000




{\displaystyle S_{1000}}




This approximates the   zeta function   for   S=2,   whose exact value

 



ζ
(
2
)
=



π

2


6




{\displaystyle \zeta (2)={\pi ^{2} \over 6}}


is the solution of the Basel problem.




  [ $ "bigrat.qky" loadfile ] now!
 
  [ 0 n->v rot times
      [ i^ 1+ 2 ** n->v 1/v v+ ] ] is sots ( n --> n/d )
 
  1000 sots
  2dup
  proper 1000000 round improper
 
  say "Sum of the series to n=1000."
  cr cr
  say "As a proper fraction, best approximation where the denominator does not exceed 1 million."
  cr cr
  proper$ echo$ say " (Correct to ten places after the decimal point.)"
  cr cr 
  say "As a decimal fraction, first 1000 places after the decimal point."
  cr cr 
  1000 point$ echo$