Hai Team
i am new to Java programming language.i want to write a program on printing the sum of harmonic
series for a given value of 'n' 1+1/2+1/3.......1/n
please do help me on this issue along with the code
Thanks in Advance
kundan
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Hai Team
i am new to Java programming language.i want to write a program on printing the sum of harmonic
series for a given value of 'n' 1+1/2+1/3.......1/n
please do help me on this issue along with the code
Thanks in Advance
kundan
public double sumHarm(int n){ int total = 0; for(int i = 1; i <= n; i++) total += (1.0/i); return total; }
Something like that should do it.
Regards,
Chris
Hi Chris
Thanks alot it worked out for me
thank you very much
have a great day