0

I have :

Stream.of(120, 410, 85, 32, 314, 12)

I tried, but seems it not right:

Stream.of(120, 410, 85, 32, 314, 12).reduce((a, b) -> b * b / a);
G T
  • 57
  • 1
  • 6
  • 1
    Duplicate question. Check this [answer](https://stackoverflow.com/a/23661052/10343888). – fatih Feb 22 '22 at 10:04

1 Answers1

0

This is an easier way to solve it:

double average = IntStream.of(120, 410, 85, 32, 314, 12)
    .average()
    .getAsDouble();

System.out.println(average);

Output:

162.16666666666666

Igor Alves
  • 68
  • 7