problem with a program


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

kitcarzon
07-31-2007, 07:05 AM
Hi Mr. Feynman :

I didn't get an error with ur program
for ex.,

entrer le nombre n:
3
1.666667

what was the value of 'n' U entered as input?