Java Number Sum sumDivisors(int n)

Here you can find the source of sumDivisors(int n)

Description

sum Divisors

License

Open Source License

Declaration

public static int sumDivisors(int n) 

Method Source Code

//package com.java2s;
/* Copyright (C) 2015 Zach Ohara
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version./*ww  w  .j a  v a  2s  .com*/
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    public static int sumDivisors(int n) {
        int sum = 0;
        for (int i = 1; i < n; i++)
            if (n % i == 0)
                sum += i;
        return sum;
    }
}

Related

  1. sum_quad_endrec(long max)
  2. sumaMesFull(String sF, int n)
  3. sumAsDouble(Iterable values)
  4. SumDiffErr(float Term1Err, float Term2Err)
  5. sumDigits(String number)
  6. sumError(long samples, long count, double m2, double mean)
  7. sumFirstIntegers(final long i)
  8. sumFirstN(long n)
  9. sumFirstNDivisibleByM(long n, long m)