program main
implicit none
real(kind=8)::epsilion,i,j,k,a,n,y1,y2 ,z
epsilion=1.0D-6
y1=1.0d0
y2=0.0d0
do i=1.0d0,1.0d5,1.0d0
a=1.0d0
do n=1.0d0,i,1.0d0
a=a*(1.0d0/i)
end do
if(a>epsilion) then
continue
else
exit
end if
end do
write(*,*)"n=",n
do j=1.0d0,n,1.0d0
a=1.0d0
do k=1.0d0,j,1.0d0
a=a*(1.0d0/k)
end do
y1=a+y1
end do
write(*,*)"from 0 to n make sum y1=",y1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
do j=n,1.0d0,-1.0d0
a=1.0d0
do k=1.0d0,j,1.0d0
a=a*(1.0d0/k)
end do
y2=a+y2
end do
y2=y2+1.0D0
write(*,*)"from n to 0 make sum y2=",y2
z=exp(1.0d0)
write(*,*)"exp(1)=",z
pause
end 作者: 胡文刚 时间: 2019-9-17 12:16
为啥不一样?作者: MRW 时间: 2019-9-17 20:10