program one2n_write_file_format write(*,*)'what is N for 1+2+...N' read(*,*) n open(unit=10,file='mid.txt') a = 0 do i=1,n a=a+i c write(10,*)'At stage ',i,' the result is ', m write(10,100) i,a end do c write(*,*)'The final result is',m write(*,101)a write(*,*)'Intermidiate results are in mid.txt.' 100 format(1x,'At stage ',i3,' the result is ',f8.3) 101 format(1x,'The final result is',f8.3) end