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.




*        Sum of a series           30/03/2017
SUMSER   CSECT
         USING  SUMSER,12          base register
         LR     12,15              set addressability
         LR     10,14              save r14
         LE     4,=E'0'            s=0
         LE     2,=E'1'            i=1 
       DO WHILE=(CE,2,LE,=E'1000') do i=1 to 1000
         LER    0,2                  i
         MER    0,2                  *i
         LE     6,=E'1'              1
         DER    6,0                  1/i**2
         AER    4,6                  s=s+1/i**2
         AE     2,=E'1'              i=i+1
       ENDDO    ,                  enddo i
         LA     0,4                format F13.4
         LER    0,4                s
         BAL    14,FORMATF         call formatf
         MVC    PG(13),0(1)        retrieve result
         XPRNT  PG,80              print buffer
         BR     10                 exit
         COPY   FORMATF            formatf code
PG       DC     CL80' '            buffer
         END    SUMSER