Java examples for Lambda Stream:IntStream
get Proper Divisors via IntStream
//package com.java2s; import java.util.ArrayList; import java.util.List; import java.util.stream.IntStream; public class Main { public static List<Integer> getProperDivisors(int number) { List<Integer> properDivisors = new ArrayList<>(); IntStream.range(1, (number / 2) + 1) .filter(divisor -> number % divisor == 0) .forEach(i -> properDivisors.add(i)); return properDivisors; } }//from www . j a v a 2s .c om