get Proper Divisors Sum via IntStream - Java Lambda Stream

Java examples for Lambda Stream:IntStream

Description

get Proper Divisors Sum via IntStream

Demo Code


    //package com.java2s;

    import java.util.stream.IntStream;

    public class Main {
        public static int getProperDivisorsSum(int number) {
   return IntStream.range(1, (number / 2) + 1).filter(divisor -> number % divisor == 0).sum();
}
    }//from  w w w .  j a v a 2  s .co  m

Related Tutorials