vaneck: Generate a sequence 'invented' by Jan Ritsema Van Eck

View source: R/vanEck.R

vaneckR Documentation

Generate a sequence 'invented' by Jan Ritsema Van Eck

Description

This function generates an interesting (to the author, at least) sequence listed as number A181391 in the https://oeis.org/. See Details for a full description.

Usage

vaneck(howlong = 100, ve = NULL, ...)

Arguments

howlong

How many terms to generate.

ve

Optional argument. Enter a previously generated ("VanEck") sequence here as a numeric vector, or a single integer to use as an initiator.

...

reserved for possible future use.

Details

The rule here is that you start with 0, and whenever you get to a number you have not seen before, the following term is a 0. But if the number k has appeared previously in the sequence, then you count the number of terms since the last appearance of k, and that number is the following term. In more detail:

Term 1: The first term is 0 by definition. Term 2: Since we havent seen 0 before, the second term is 0. Term 3: Since we have seen a 0 before, one step back, the third term is 1 Term 4: Since we havent seen a 1 before, the fourth term is 0 Term 5: Since we have seen a 0 before, two steps back, the fifth term is 2. And so on. As of this release of this R-package, how fast max(sequence) grows, and whether every number eventually appears, are open questions. The latest investigations and theorems related to this sequence can be found at https://oeis.org/A181391/

Value

ve

The vector (ve for "VanEck") of the sequence values calculated

uniqs

a vector of the unique values in ve

Author(s)

Carl Witthoft, carl@witthoft.com

References

https://oeis.org/A181391/

Examples

(vaneck(20))
# $ve
#  [1] 0 0 1 0 2 0 2 2 1 6 0 5 0 2 6 5 4 0 5 3 0
# $uniqs
# [1] 0 1 2 6 5 4 3


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