guilhermemarques
Programmer
- Jun 15, 2009
- 3
Hey guys,
I have to program a Fortran code to solve the problem: S = 1/1 + 1/2 + ... + 1/T to get the largest S possible.
Actually my fortran program is like:
program test
implicit none
real :: T = 17000000, S = 0;
do while (T<17000000)
S = S + 1/T
T = T + 1
end do
print *,"S Value = ",S
end program test
And it just don´t solve the problem, for example, with a T value 16000000 the program solves. So i think it´s the precision of the real variable...
How can i solve this problema in Fortran?
Thanks in advance.
I have to program a Fortran code to solve the problem: S = 1/1 + 1/2 + ... + 1/T to get the largest S possible.
Actually my fortran program is like:
program test
implicit none
real :: T = 17000000, S = 0;
do while (T<17000000)
S = S + 1/T
T = T + 1
end do
print *,"S Value = ",S
end program test
And it just don´t solve the problem, for example, with a T value 16000000 the program solves. So i think it´s the precision of the real variable...
How can i solve this problema in Fortran?
Thanks in advance.