Write a program in Java to find the sum of the given series:
Categories: Core Java Java 8(JDK1.8) Experienced Freshers Java Lambda Class 11 Series Programming
//Write a program in Java to find the sum of the given series:
//S = a + a2 / 2 + a3 / 3 + …… + a10 / 10
// JDK1.8
package r4rin.com.Series;
import java.util.stream.Stream;
public class FindTheSumOfTheSeries2 {
public static void main(String[] args) {
int a=2;
double sum=Stream.iterate(1,n->n+1).limit(10).mapToDouble(i->Math.pow(a, i)/i).sum();
System.out.println("sum="+sum);
}
}