Title: | Integer Sequence Generator |
---|---|
Description: | Generates well-known integer sequences. 'gmp' package is adopted for computing with arbitrarily large numbers. Every function has hyperlink to its corresponding item in OEIS (The On-Line Encyclopedia of Integer Sequences) in the function help page. For interested readers, see Sloane and Plouffe (1995, ISBN:978-0125586306). |
Authors: | Kisung You [aut, cre] |
Maintainer: | Kisung You <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.2.1 |
Built: | 2025-02-02 02:39:10 UTC |
Source: | https://github.com/kisungyou/zseq |
The world of integer sequence has long history, which has been accumulated in The On-Line Encyclopedia of Integer Sequences.
Even though R
is not a first pick for many number theorists, we introduce our package to enrich the R
ecosystem as well as
provide pedagogical toolset. We adopted gmp for flexible large number computations in that users can easily experience
large number sequences on a non-exclusive generic computing platform.
Under OEIS A005101, an abundant number is a number whose proper divisors sum up to the extent greater than the number itself. First 6 abundant numbers are 12, 18, 20, 24, 30, 36.
Abundant(n, gmp = TRUE)
Abundant(n, gmp = TRUE)
n |
the number of first |
gmp |
a logical; |
a vector of length n
containing first entries from the sequence.
## generate first 30 Abundant numbers and print it print(Abundant(30))
## generate first 30 Abundant numbers and print it print(Abundant(30))
Under OEIS A052486, an Achilles number is a number that is powerful but not perfect. First 6 Achilles numbers are 72, 108, 200, 288, 392, 432.
Achilles(n, gmp = TRUE)
Achilles(n, gmp = TRUE)
n |
the number of first |
gmp |
a logical; |
a vector of length n
containing first entries from the sequence.
## generate first 3 Achilles numbers and print print(Achilles(3))
## generate first 3 Achilles numbers and print print(Achilles(3))
Under OEIS A000110, the nth Bell number is
the number of ways to partition a set of n
labeled elements,
where the first 6 entries are 1, 1, 2, 5, 15, 52.
Bell(n, gmp = TRUE)
Bell(n, gmp = TRUE)
n |
the number of first |
gmp |
a logical; |
a vector of length n
containing first entries from the sequence.
## generate first 30 Bell numbers and print print(Bell(30))
## generate first 30 Bell numbers and print print(Bell(30))
Under OEIS A002997, a Carmichael number is
a composite number such that
for all integers which are relatively prime to
. First 6 Carmichael numbers are 561, 1105, 1729, 2465, 2821, 6601.
Carmichael(n, gmp = TRUE)
Carmichael(n, gmp = TRUE)
n |
the number of first |
gmp |
a logical; |
a vector of length n
containing first entries from the sequence.
## generate first 3 Carmichael numbers print(Carmichael(3))
## generate first 3 Carmichael numbers print(Carmichael(3))
Under OEIS A000108, the nth Catalan number is given as
where the first 6 entries are 1, 1, 2, 5, 14, 42 with
Catalan(n, gmp = TRUE)
Catalan(n, gmp = TRUE)
n |
the number of first |
gmp |
a logical; |
a vector of length n
containing first entries from the sequence.
## generate first 30 Catalan numbers print(Catalan(30))
## generate first 30 Catalan numbers print(Catalan(30))
Under OEIS A002808, a composite number is a positive integer that can be represented as multiplication of two smaller positive integers. The first 6 composite numbers are 4, 6, 8, 9, 10, 12.
Composite(n, gmp = TRUE)
Composite(n, gmp = TRUE)
n |
the number of first |
gmp |
a logical; |
a vector of length n
containing first entries from the sequence.
## generate first 30 Composite numbers print(Composite(30))
## generate first 30 Composite numbers print(Composite(30))
Under OEIS A005100, a deficient number is a number whose proper divisors sum up to the extent smaller than the number itself. First 6 deficient numbers are 1, 2, 3, 4, 5, 7
Deficient(n, gmp = TRUE)
Deficient(n, gmp = TRUE)
n |
the number of first |
gmp |
a logical; |
a vector of length n
containing first entries from the sequence.
## generate first 30 Deficient numbers print(Deficient(30))
## generate first 30 Deficient numbers print(Deficient(30))
Under OEIS A046758, an Equidigital number has equal digits as the number of digits in its prime factorization including exponents. First 6 Equidigital numbers are 1, 2, 3, 5, 7, 10. Though it doesn't matter which base we use, here we adopt only a base of 10.
Equidigital(n, gmp = TRUE)
Equidigital(n, gmp = TRUE)
n |
the number of first |
gmp |
a logical; |
a vector of length n
containing first entries from the sequence.
## generate first 20 Equidigital numbers print(Equidigital(20))
## generate first 20 Equidigital numbers print(Equidigital(20))
Under OEIS A001969, an Evil number has an even number of 1's in its binary expansion. First 6 Evil numbers are 0, 3, 5, 6, 9, 10.
Evil(n, gmp = TRUE)
Evil(n, gmp = TRUE)
n |
the number of first |
gmp |
a logical; |
a vector of length n
containing first entries from the sequence.
## generate first 20 Evil numbers print(Evil(20))
## generate first 20 Evil numbers print(Evil(20))
Under OEIS A046760, an Extravagant number has less digits than the number of digits in its prime factorization including exponents. First 6 Extravagant numbers are 4, 6, 8, 9, 12, 18. Though it doesn't matter which base we use, here we adopt only a base of 10.
Extravagant(n, gmp = TRUE)
Extravagant(n, gmp = TRUE)
n |
the number of first |
gmp |
a logical; |
a vector of length n
containing first entries from the sequence.
## generate first 20 Extravagant numbers print(Extravagant(20))
## generate first 20 Extravagant numbers print(Extravagant(20))
Under OEIS A000142, a Factorial is the product of all positive integers smaller than or equal to the number. First 6 such numbers are 1, 1, 2, 6, 24, 120
Factorial(n, gmp = TRUE)
Factorial(n, gmp = TRUE)
n |
the number of first |
gmp |
a logical; |
a vector of length n
containing first entries from the sequence.
## generate first 10 Factorials print(Factorial(10))
## generate first 10 Factorials print(Factorial(10))
Under OEIS A005165, an Alternating Factorial is the absolute value of the alternating sum of the
first n
factorials of positive integers. First 6 such numbers are 0, 1, 1, 5, 19, 101.
Factorial.Alternating(n, gmp = TRUE)
Factorial.Alternating(n, gmp = TRUE)
n |
the number of first |
gmp |
a logical; |
a vector of length n
containing first entries from the sequence.
## generate first 5 Alternating Factorial numbers print(Factorial.Alternating(5))
## generate first 5 Alternating Factorial numbers print(Factorial.Alternating(5))
Under OEIS A000165 and A001147, a Double Factorial is the factorial of numbers with same parity.
For example, if , then
.
Factorial.Double(n, gmp = TRUE, odd = TRUE)
Factorial.Double(n, gmp = TRUE, odd = TRUE)
n |
the number of first |
gmp |
a logical; |
odd |
a logical; |
a vector of length n
containing first entries from the sequence.
## generate first 10 double factorials print(Factorial.Double(10))
## generate first 10 double factorials print(Factorial.Double(10))
Under OEIS A000045, the nth Fibonnaci number is given as
where the first 6 entries are 0, 1, 1, 2, 3, 5 with
Fibonacci(n, gmp = TRUE)
Fibonacci(n, gmp = TRUE)
n |
the number of first |
gmp |
a logical; |
a vector of length n
containing first entries from the sequence.
## generate first 30 Fibonacci numbers print(Fibonacci(30))
## generate first 30 Fibonacci numbers print(Fibonacci(30))
Under OEIS A046759, a Frugal number has more digits than the number of digits in its prime factorization including exponents. First 6 Frugal numbers are 125, 128, 243, 256, 343, 512. Though it doesn't matter which base we use, here we adopt only a base of 10.
Frugal(n, gmp = TRUE)
Frugal(n, gmp = TRUE)
n |
the number of first |
gmp |
a logical; |
a vector of length n
containing first entries from the sequence.
## generate first 5 Frugal numbers print(Frugal(5))
## generate first 5 Frugal numbers print(Frugal(5))
Under OEIS A007770, a Happy number is defined by the process that starts from arbitrary positive integer and replaces the number by the sum of the squares of each digit until the number is 1. First 6 Happy numbers are 1, 7, 10, 13, 19, 23.
Happy(n, gmp = TRUE)
Happy(n, gmp = TRUE)
n |
the number of first |
gmp |
a logical; |
a vector of length n
containing first entries from the sequence.
## generate first 30 happy numbers print(Happy(30))
## generate first 30 happy numbers print(Happy(30))
Under OEIS A094683, a Juggler sequence is an integer-valued
sequence that starts with a nonnegative number iteratively follows that if
is even, or
if odd.
No first 6 terms are given since it all depends on the starting value.
Juggler(start, gmp = TRUE)
Juggler(start, gmp = TRUE)
start |
the starting nonnegative integer. |
gmp |
a logical; |
a vector recording the sequence of unknown length a priori.
## let's start from 9 and show the sequence print(Juggler(9))
## let's start from 9 and show the sequence print(Juggler(9))
Under OEIS A094716, the Largest value for Juggler sequence is the largest value in trajectory of
a sequence that starts from n
. First 6 terms are 0, 1, 2, 36, 4, 36 that n
starting from 0 is conventional choice.
Juggler.Largest(n, gmp = TRUE)
Juggler.Largest(n, gmp = TRUE)
n |
the number of first |
gmp |
a logical; |
a vector of length n
containing first entries from the sequence.
## generate first 10 numbers of largest values for Juggler sequences print(Juggler.Largest(10))
## generate first 10 numbers of largest values for Juggler sequences print(Juggler.Largest(10))
Under OEIS A007320, a Number of steps for Juggler sequence literally counts the number of steps
required for a sequence that starts from n
. First 6 terms are 0, 1, 6, 2, 5, 2 that n
starting from 0 is conventional choice.
Note that when it counts number of steps, not the length of the sequence including the last 1.
Juggler.Nsteps(n, gmp = TRUE)
Juggler.Nsteps(n, gmp = TRUE)
n |
the number of first |
gmp |
a logical; |
a vector of length n
containing first entries from the sequence.
## generate first 10 numbers of steps for Juggler sequences print(Juggler.Nsteps(10))
## generate first 10 numbers of steps for Juggler sequences print(Juggler.Nsteps(10))
Under OEIS A000032, the nth Lucas number is given as
where the first 6 entries are 2, 1, 3, 4, 7, 11.
Lucas(n, gmp = TRUE)
Lucas(n, gmp = TRUE)
n |
the number of first |
gmp |
a logical; |
a vector of length n
containing first entries from the sequence.
## generate first 30 Lucas numbers print(Lucas(30))
## generate first 30 Lucas numbers print(Lucas(30))
Under OEIS A001006, a Motzkin number for a given n is the number of ways for drawing non-intersecting chords among n points on a circle, where the first 7 entries are 1, 1, 2, 4, 9, 21, 51.
Motzkin(n, gmp = TRUE)
Motzkin(n, gmp = TRUE)
n |
the number of first |
gmp |
a logical; |
a vector of length n
containing first entries from the sequence.
## generate first 30 Motzkin numbers print(Motzkin(30))
## generate first 30 Motzkin numbers print(Motzkin(30))
Under OEIS A000069, an Odious number has an odd number of 1's in its binary expansion. First 6 Odious numbers are 1, 2, 4, 7, 8, 11.
Odious(n, gmp = TRUE)
Odious(n, gmp = TRUE)
n |
the number of first |
gmp |
a logical; |
a vector of length n
containing first entries from the sequence.
## generate first 20 Odious numbers print(Odious(20))
## generate first 20 Odious numbers print(Odious(20))
Under OEIS A000931, the nth Padovan number is given as
where the first 6 entries are 1, 0, 0, 1, 0, 1.
Padovan(n, gmp = TRUE)
Padovan(n, gmp = TRUE)
n |
the number of first |
gmp |
a logical; |
a vector of length n
containing first entries from the sequence.
## generate first 30 Padovan numbers print(Padovan(30))
## generate first 30 Padovan numbers print(Padovan(30))
Under OEIS A002113, a Palindromic number is a number that
remains the same when its digits are reversed. First 6 Palindromic numbers in decimal are 0, 1, 2, 3, 4, 5.
This function supports various base by specifying the parameter base
but returns are still represented in decimal.
Palindromic(n, base = 10, gmp = TRUE)
Palindromic(n, base = 10, gmp = TRUE)
n |
the number of first |
base |
choice of base. |
gmp |
a logical; |
a vector of length n
containing first entries from the sequence.
## generate first 30 palindromic number in decimal print(Palindromic(30))
## generate first 30 palindromic number in decimal print(Palindromic(30))
Under OEIS A002779, a Palindromic square is a number that is both Palindromic and Square. First 6 such numbers are 0, 1, 4, 9, 121, 484. It uses only the base 10 decimals.
Palindromic.Squares(n, gmp = TRUE)
Palindromic.Squares(n, gmp = TRUE)
n |
the number of first |
gmp |
a logical; |
a vector of length n
containing first entries from the sequence.
## generate first 10 palindromic squares print(Palindromic.Squares(10))
## generate first 10 palindromic squares print(Palindromic.Squares(10))
Under OEIS A000396, a Perfect number is a number whose proper divisors sum up to the extent equal to the number itself. First 6 abundant numbers are 6, 28, 496, 8128, 33550336, 8589869056.
Perfect(n, gmp = TRUE)
Perfect(n, gmp = TRUE)
n |
the number of first |
gmp |
a logical; |
a vector of length n
containing first entries from the sequence.
## Not run: ## generate first 7 Perfect numbers print(Perfect(10)) ## End(Not run)
## Not run: ## generate first 7 Perfect numbers print(Perfect(10)) ## End(Not run)
Under OEIS A001608, the nth Perrin number is given as
where the first 6 entries are 3, 0, 2, 3, 2, 5.
Perrin(n, gmp = TRUE)
Perrin(n, gmp = TRUE)
n |
the number of first |
gmp |
a logical; |
a vector of length n
containing first entries from the sequence.
## generate first 30 Perrin numbers print(Perrin(30))
## generate first 30 Perrin numbers print(Perrin(30))
Under OEIS A001694, a Powerful number is a positive integer such that
for every prime dividing the number,
also divides the number. First
6 powerful numbers are 1, 4, 8, 9, 16, 25.
Powerful(n, gmp = TRUE)
Powerful(n, gmp = TRUE)
n |
the number of first |
gmp |
a logical; |
a vector of length n
containing first entries from the sequence.
## generate first 20 Powerful numbers print(Powerful(20))
## generate first 20 Powerful numbers print(Powerful(20))
Under OEIS A000040, a Prime number is a natural number with no positive divisors other than 1 and itself. First 6 prime numbers are 2, 3, 5, 7, 11, 13.
Prime(n, gmp = TRUE)
Prime(n, gmp = TRUE)
n |
the number of first |
gmp |
a logical; |
a vector of length n
containing first entries from the sequence.
## generate first 30 Regular numbers print(Prime(30))
## generate first 30 Regular numbers print(Prime(30))
Under OEIS A051037, a Regular number - also known as 5-smooth - is a positive integer that even divide powers of 60, or equivalently, whose prime divisors are only 2,3, and 5. First 6 Regular numbers are 1, 2, 3, 4, 5, 6.
Regular(n, gmp = TRUE)
Regular(n, gmp = TRUE)
n |
the number of first |
gmp |
a logical; |
a vector of length n
containing first entries from the sequence.
## generate first 20 Regular numbers print(Regular(20))
## generate first 20 Regular numbers print(Regular(20))
Under OEIS A000290, a Square number is
for . First 6 Square numbers are 0, 1, 4, 9, 16, 25.
Square(n, gmp = TRUE)
Square(n, gmp = TRUE)
n |
the number of first |
gmp |
a logical; |
a vector of length n
containing first entries from the sequence.
## generate first 20 Square numbers print(Square(20))
## generate first 20 Square numbers print(Square(20))
Under OEIS A005117, a Squarefree number is a number that are not divisible by a square of a smaller integer greater than 1. First 6 Squarefree numbers are 1, 2, 3, 5, 6, 7.
Squarefree(n, gmp = TRUE)
Squarefree(n, gmp = TRUE)
n |
the number of first |
gmp |
a logical; |
a vector of length n
containing first entries from the sequence.
## generate first 30 Squarefree numbers print(Squarefree(30))
## generate first 30 Squarefree numbers print(Squarefree(30))
Under OEIS A000085, a Telephone number - also known as Involution number - is counting the number
of connection patterns in a telephone system with n
subscribers, or in a more mathematical term, the number of self-inverse permutations on
n
letters. First 6 Telephone numbers are 1, 1, 2, 4, 10, 26,
Telephone(n, gmp = TRUE)
Telephone(n, gmp = TRUE)
n |
the number of first |
gmp |
a logical; |
a vector of length n
containing first entries from the sequence.
## generate first 20 Regular numbers print(Telephone(20))
## generate first 20 Regular numbers print(Telephone(20))
Under OEIS A055010, the nth Thabit number is given as
where the first 6 entries are 0, 2, 5, 11, 23, 47 with
Thabit(n, gmp = TRUE)
Thabit(n, gmp = TRUE)
n |
the number of first |
gmp |
a logical; |
a vector of length n
containing first entries from the sequence.
## generate first 30 Thabit numbers print(Thabit(30))
## generate first 30 Thabit numbers print(Thabit(30))
Under OEIS A000217, a Triangular number counts objects arranged in an equilateral triangle. First 6 Triangular numbers are 0, 1, 3, 6, 10, 15.
Triangular(n, gmp = TRUE)
Triangular(n, gmp = TRUE)
n |
the number of first |
gmp |
a logical; |
a vector of length n
containing first entries from the sequence.
## generate first 20 Triangular numbers print(Triangular(20))
## generate first 20 Triangular numbers print(Triangular(20))
Under OEIS A064052, an Unusual number is a natural number whose largest prime factor is strictly greater than square root of the number. First 6 Unusual numbers are 2, 3, 5, 6, 7, 10.
Unusual(n, gmp = TRUE)
Unusual(n, gmp = TRUE)
n |
the number of first |
gmp |
a logical; |
a vector of length n
containing first entries from the sequence.
## generate first 20 Unusual numbers print(Unusual(20))
## generate first 20 Unusual numbers print(Unusual(20))