Hi(adsbygoogle = window.adsbygoogle || []).push({});

Here is my code to get the sum of harmonic series. Harmonic series is

[tex]\sum_{i=1}^{\infty}\; \frac{1}{i} [/tex]

here is the code

Now if I give n= 10000000 , it gives me the answer 15.403683. But Mathematica gives me answer 16.6953. So there is something wrong happening in this simple code.Code (Text):program harmonic

implicit none

integer :: i,n

real :: sum=0.0

write(*,*)'How many terms you want to sum ?'

read(*,*) n

do i= 1 ,n

sum=sum +(1.0/real(i))

end do

write(*,*) 'The sum of series is = ', sum

end program harmonic

Can anybody point out the mistake ?

**Physics Forums - The Fusion of Science and Community**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# FORTRAN program for harmonic series sum

Loading...

Similar Threads - FORTRAN program harmonic | Date |
---|---|

How to buy Fortran Programming Software Commersial License | Jan 30, 2018 |

Fortran 90/95 function | Dec 17, 2015 |

Input/Output error with error code -5 | Dec 16, 2015 |

Large/Infinite results | Jun 18, 2015 |

**Physics Forums - The Fusion of Science and Community**