c     I won't go into detail for FORTRAN, because if you don't know either
c     language, you're better off learning C

      program printjunk
      implicit none
      double precision fredbar,x(10)
      double precision fred,PI
      double complex ci
      double complex z
      integer i
      
      PI=4.d0*atan(1.d0)
      ci=(0.d0,1.d0)
      do i=0,8
         z=cdexp(i*ci*PI/4.0)
         write(6,*) 'For phi=',0.25*i,'PI,   e^{i phi}=',z
      enddo

      fredbar=0.d0
      open(unit=22,file='crap.dat')
      do i=1,10
         fredbar=fredbar+fred(i,x(i))
         write(6,*) "for i=",i,", x=",x(i)
         write(22,*) "for i=",i,", x=",x(i)
      enddo
      fredbar=fredbar/10.d0
      write(6,234) fredbar
 234  format("Average fred=",f10.4)
      stop
      end
         

      double precision function fred(i,x)
      integer i
      double precision x,answer
      x=1.0/dreal(i)
      answer=i*i+(-1)**i
      fred=answer
      return
      end
