fork(2) download
  1. import java.util.stream.IntStream;
  2.  
  3. class Main {
  4. public static void main(String[] args) {
  5.  
  6. IntStream stream = IntStream.range(1, 1000);
  7. long result = stream.reduce(0, (sum, value) -> (value % 3 == 0 || value % 5 == 0) ? sum+value : sum);
  8.  
  9. System.out.println(result);
  10. }
  11. }
Success #stdin #stdout 0.14s 4386816KB
stdin
Standard input is empty
stdout
233168