# View Source Multitool.Numbers.Factors(multitool v0.3.0)

Provides operations for working with the factors of numbers

A factor of a number `x` is any number which divides `x` without a remainder.

If `x` was `10`, the factors of `x` would be `[1, 2, 5, 10]`

# Link to this section Summary

## Functions

Given a number `n`, calculates the sum of all proper divisors of `n`, other than `n` itself

Given a number `n`, classifies `n` as either pefect, abundant, or deficient

Given a number `n`, retrieve a list of all factors for that number

Given an integer `n` and `sum_type`, returns true if `n` can be represented as the sum of two numbers of the given type

Given a range `range`, returns a list of integers that can be represented as the sum of two abundant numbers

Given an integer `n` and `sum_type`, returns a list of tuples containg two numbers of the given type which sum to equal `n`

# aliquot_sum(n)

View Source

Given a number `n`, calculates the sum of all proper divisors of `n`, other than `n` itself

## parameters Parameters

``n: A non-negative integer``

## examples Examples

``````iex> aliquot_sum(3)
1
iex> aliquot_sum(12)
16
iex> aliquot_sum(100)
117``````

# classify(n)

View Source

Given a number `n`, classifies `n` as either pefect, abundant, or deficient

If the aliquot sum of `n` is equal to `n`, `n` is perfect. If the sum exceeds `n`, it is abundant. Otherwise, it is deficient

## parameters Parameters

``n: A non-negative integer``

## examples Examples

``````iex> classify(3)
:deficient
iex> classify(12)
:abundant
iex> classify(28)
:perfect``````

# factors_of(n)

View Source (since 0.1.0)

Given a number `n`, retrieve a list of all factors for that number

If `n` is less than one, return an empty list. The resulting list is not sorted.

## parameters Parameters

``n: The number to retrieve factors of ``

## examples Examples

``````iex> factors_of(3)
[1, 3]
iex> factors_of(0)
[]
iex> factors_of(100)
[1, 100, 2, 50, 4, 25, 5, 20, 10]``````

# sum_type?(n, sum_type)

View Source

Given an integer `n` and `sum_type`, returns true if `n` can be represented as the sum of two numbers of the given type

Always returns true if n is greater than 28123 and the type is abundant. False if less than one. All other values are computed

## parameters Parameters

``````n: An integer
sum_type: An atom of either :abundant, :deficient, or :perfect``````

## examples Examples

``````iex> sum_type?(24, :abundant)
true
iex> sum_type?(12, :perfect)
true
iex> sum_type?(14, :deficient)
true``````

# sums_in(range, sum_type)

View Source

Given a range `range`, returns a list of integers that can be represented as the sum of two abundant numbers

If no numbers in the range are the sum of two abundant numbers, an empty list is returned

## parameters Parameters

``range: An integer range``

## examples Examples

``````iex> sums_in(1..25, :abundant)
[24]
iex> sums_in(1..5, :deficient)
[2, 3, 4, 5]
iex> sums_in(1..1000, :perfect)
[12, 34, 56, 502, 524, 992]``````

# sums_of_type(n, sum_type)

View Source

Given an integer `n` and `sum_type`, returns a list of tuples containg two numbers of the given type which sum to equal `n`

If no two numbers of the given type sum to `n`, an empty list is returned. An empty list is returned for integers below one

## parameters Parameters

``````n: An integer
sum_type: An atom of either :abundant, :deficient, or :perfect``````

## examples Examples

``````iex> sums_of_type(100, :abundant)
[{12, 88}, {20, 80}, {30, 70}, {40, 60}]
iex> sums_of_type(5, :deficient)
[{1, 4}, {2, 3}]
iex> sums_of_type(12, :perfect)
[{6, 6}]``````