What are the divisors of 400?
1, 2, 4, 5, 8, 10, 16, 20, 25, 40, 50, 80, 100, 200, 400
- There is a total of 15 positive divisors.
- The sum of these divisors is 961.
- The arithmetic mean is 64.066666666667.
12 even divisors
2, 4, 8, 10, 16, 20, 40, 50, 80, 100, 200, 400
3 odd divisors
1, 5, 25
How to compute the divisors of 400?
A number N is said to be divisible by a number M (with M non-zero) if, when we divide N by M, the remainder of the division is zero.
Brute force algorithm
We could start by using a brute-force method which would involve dividing 400 by each of the numbers from 1 to 400 to determine which ones have a remainder equal to 0.
(where is the integer part of the quotient)
- 400 / 1 = 400 (the remainder is 0, so 1 is a divisor of 400)
- 400 / 2 = 200 (the remainder is 0, so 2 is a divisor of 400)
- 400 / 3 = 133.33333333333 (the remainder is 1, so 3 is not a divisor of 400)
- ...
- 400 / 399 = 1.0025062656642 (the remainder is 1, so 399 is not a divisor of 400)
- 400 / 400 = 1 (the remainder is 0, so 400 is a divisor of 400)
Improved algorithm using square-root
However, there is another slightly better approach that reduces the number of iterations by testing only integers less than or equal to the square root of 400 (i.e. 20). Indeed, if a number N has a divisor D greater than its square root, then there is necessarily a smaller divisor d such that:
(thus, if , then )
- 400 / 1 = 400 (the remainder is 0, so 1 and 400 are divisors of 400)
- 400 / 2 = 200 (the remainder is 0, so 2 and 200 are divisors of 400)
- 400 / 3 = 133.33333333333 (the remainder is 1, so 3 is not a divisor of 400)
- ...
- 400 / 19 = 21.052631578947 (the remainder is 1, so 19 is not a divisor of 400)
- 400 / 20 = 20 (the remainder is 0, so 20 and 20 are divisors of 400)