Where is the error?!


Feynman
06-28-2007, 10:08 AM
Good morning,
I m a beginner on the fortran,
I write a program to calculate the sum from i=1 to n of 1/i!
and i have one error, but i don t know how to delete these error, could you help me?
thank you
this is my program :

program expo
implicit none
integer n,j
real sum
print* ,'entrer le nombre n:'
read*,n
sum=0.0
do j=1,n
sum=sum+1/fact(j)
end do
end

function fact(m)
integer fact, m, p
p = 1
do i = 1, m
p = p * i
end do
fact = p
end function fact

txhughes
07-08-2007, 06:53 PM
Hi, can you post the error message you are receiving?

#Janet#
07-10-2007, 07:22 AM
Feynman, your code works fine for me. But it if you use incorrect n in
read*,n
you can get math error
good luck

___________
Janet Kellman, software reviews (http://rbytes.net/software/)