[Fortran] 纯文本查看 复制代码
PROGRAM MAIN
IMPLICIT NONE
REAL X,S
INTEGER*8 N
INTEGER I
INTEGER,EXTERNAL :: FACT
READ(*,*) N
READ(*,*) X
S=0
DO 10 I=2,N
S=S+X**I/FACT(I)
WRITE(*,*) I,FACT(I),X**I,
10 CONTINUE
S=S+X+1
WRITE(*,*) S
END
RECURSIVE INTEGER FUNCTION FACT(N) RESULT(ANS)
IMPLICIT NONE
INTEGER,INTENT(IN) :: N
IF(N>1) THEN
ANS=N*FACT(N-1)
RETURN
END IF
ANS=1
RETURN
END
[Fortran] 纯文本查看 复制代码
Program main
Implicit None
real x,s,t
integer n
integer i
read(*,*) n
read(*,*) x
t = x
s = x + 1
Do i=2,n
t = t*x/i
s = s + t
End Do
write(*,*) s
End Program main