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 av  a2 s.c o  m*/

Related Tutorials