aliquot: Generate the Aliquot sequence.

View source: R/numberseqs.R

aliquotR Documentation

Generate the Aliquot sequence.

Description

Each term in the aliquot sequence is generated by summing all proper divisors of the previous term. The value "1" is included in this collection of divisors. In number theory, aliquot is closely related to terms such as "sociable" and "amicable" numbers

Usage

aliquot(x, maxiter = 100)

Arguments

x

An integer or a bigz integer to start the desired sequence

maxiter

Set a limit on the number of terms to calculate. See Details for reasons why to do so.

Details

While many aliquot sequences terminate in the values c(prime_number, 1, 0), many numbers drop into a short loop or a repeating value (perfect numbers do this). If the sequence repeats or terminates, the sequence is returned. If either maxiter is reached or the sequence drops into a loop (and thus maxiter will be triggered), a warning notice is generated and the sequence so far is returned.

Value

A vector of bigz integers ...

Author(s)

Carl Witthoft, carl@witthoft.com

Examples

aliquot(20)
# 20 22 14 10 8  7  1
aliquot (95)
# repeats '6' forever
# 95 25 6  6

FunWithNumbers documentation built on Aug. 29, 2023, 1:06 a.m.