      program prog012
      real*8 x, sum
      write(*,*) 'n, x = ?'
      read(*,*) n, x
      write(*,*) 'n, x = ',n,x
c
c $BA22=<0$rMxMQ$7$?7W;;$NNc(B
c
c     S(0)=1
c     S(k)=S(k-1)*x + 1
c     sum =S(n)
c
      sum = 1.0d0	! 1.0 $B$N$3$H$@$,!"$:$C$H(B 0 $B$,B3$$$F$$$k$3$H$r<($9!#(B
      do k = 1, n
         sum = sum*x + 1.0d0
      end do
c
      write(*,*) 'sum   = ',sum
      if(x.eq.1.0d0) then
         write(*,*) 'Exact = ',n+1
      else
         write(*,*) 'Exact = ',(1.0d0-x**(n+1))/(1.0d0-x)
      endif
      stop
      end
