Java Utililty Methods Number Sum

List of utility methods to do Number Sum

Description

The list of methods to do Number Sum are organized into topic(s).

Method

intsumMinMax(int a, int b)
sum Min Max
int localSum = a + b;
return localSum < 0 ? 0 : (localSum > 255 ? 255 : localSum);
longsumNforOddIndices(long n)
sum Nfor Odd Indices
n = (n - 1) / 2;
return getFibonnaci(2 * n + 2);
doublesumOfCollectionDouble(Iterable doubleIterable)
Returns the sum of the values within an Double Iterable .
double retval = 0;
for (Double iValue : doubleIterable) {
    if (iValue != null) {
        retval += iValue;
return retval;
longsumOfDigits(long n)
Return sum of decimal digits in n.
long i = n;
long sum = 0;
while (i > 0) {
    sum = sum + (i % 10);
    i = i / 10;
return sum;
longsumOfProperDivisors(long num)
sum Of Proper Divisors
if (num == 1) {
    return 0;
long sum = 1; 
long root = (long) Math.sqrt((double) num);
if (root * root == num) {
    sum += root;
    root -= 1;
...
NumbersumOr0(Object a, Object b)
sum Or
if (isValidNumber(a) && isValidNumber(b)) {
    if (a instanceof Long || a instanceof Integer) {
        return ((Number) a).longValue() + ((Number) b).longValue();
    } else {
        return ((Number) a).doubleValue() + ((Number) b).doubleValue();
return 0;
...
intsumOverOne(final int n)
sum Over One
return (n * (n + 1)) / 2;
doublesumPossitiveIntegerSequencePartial(int start, int end)
sum Possitive Integer Sequence Partial
double largeSum = .5 * end * (end + 1);
double smallSum = .5 * start * (start + 1);
return largeSum - smallSum;
doublesumUp(final Iterable values)
sum Up
double sum = 0.0;
for (final T value : values) {
    sum += value.doubleValue();
return sum;