Feynman

07-11-2007, 05:52 AM

hello,

i wrote a program to calculate the sum of 1/n! the compilation completed with no errors but when i run the program it gives me an error for big numbers so where is the error?!

i join the program below

program expo

implicit none

integer n,j

real sum, fact

print* ,'entrer le nombre n:'

read*,n

sum=0.0

do j=1,n

sum=sum+1./fact(j)

end do

print *, sum

end

function fact(m)

real fact

integer m, p

p = 1

do i = 1, m

p = p * i

end do

fact = p

end

thank you very much

i wrote a program to calculate the sum of 1/n! the compilation completed with no errors but when i run the program it gives me an error for big numbers so where is the error?!

i join the program below

program expo

implicit none

integer n,j

real sum, fact

print* ,'entrer le nombre n:'

read*,n

sum=0.0

do j=1,n

sum=sum+1./fact(j)

end do

print *, sum

end

function fact(m)

real fact

integer m, p

p = 1

do i = 1, m

p = p * i

end do

fact = p

end

thank you very much