请写一个method of continued fractions 的fortran 程序计算 电子原子散射
program ContinuedFractions
implicit none
integer :: i,n
real :: x,y,a(100)
! input the scattering angle and the number of terms in the series
write(*,'("Input scattering angle (in radians):")')
read(*,*) x
write(*,'("Input number of terms:")')
read(*,*) n
! compute the continued fraction for the scattering angle
a(1) = x
do i=2,n-1
if (i .eq. 2) then
y = 0.5*x**2/a(1) ! initial value for y
elseif (modulo(i-2,4).eq.0 .or. modulo(i-2,4).eq.3 ) then ! even/odd values for y y = 1./y ! compute next value of y using previous one endif a(i) = 0.5*x**2/y enddo a(n)=x/y ! print out the results do i=1,n write(*,'("a",I3,"=",F10.6)') i,a(i) enddoend program ContinuedFractions
免责声明:
以上内容除特别注明外均来源于网友提问,创作工场回答,未经许可,严谨转载。