Sum of Reciprocal Series coderinme

Sum of Reciprocal Series coderinme

Write a java program that computes the sum of the reciprocals: 1/1 + 1/2 + 1/3 + … + 1/10

Mathematically, This is an an Arithmetic Sequence because we can clearly see that the difference between one term and the next is a constant (difference 2). In General we could write an arithmetic sequence like this:
{a, a+d, a+2d, a+3d, … }
a is the first term, and
d is the difference between the terms (called the “common difference”)
To sum up the terms of this arithmetic sequence:
a + (a+d) + (a+2d) + (a+3d) + …
use this formula:
Sum = n/2 * { 2a + (n-1) * d }

In Java, it is quiet simple:

public class Q11
public static void main(String[] args) 
float sum=0;
for(int i=1;i<=10;i++) {
System.out.println(" The sum of reciprocal is = :"+sum);

For more programs on Java, visit our Java Archives

Sum of Reciprocal Series coderinme

All rights reserved. No part of this Post may be copied, distributed, or transmitted in any form or by any means, without the prior written permission of the website admin, except in the case of brief quotations embodied in critical reviews and certain other noncommercial uses permitted by copyright law. For permission requests, write to the owner, addressed “Attention: Permissions Coordinator,” to the admin @coderinme

Leave a reply:

Your email address will not be published.