Description Usage Arguments Value Author(s) Examples
Takes in the common difference (d), the first term (a1), and the number of terms wanted (n) and stores the first n terms of that sequence in a vector
1 | arithSeq(d,a1,n)
|
d |
common difference of the sequence |
a1 |
first term of the series |
n |
number of terms to be stored in the vector |
Returns a numeric vector containing the first n terms of the sequence
Matt Heffernan, University of Illinois at Chicago
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | arithSeq(1,0,5)
Returns a vector containg a sequence of 5 terms with a common difference of 1 and an inital term of 0
(0 1 2 3 4)
##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
arithSeq <- function(d,a1,n)
{
count <- 0
sequence <- vector()
while(count < n)
{
sequence <- append(sequence, (a1 + (count)*d))
count <- count+1
}
return(sequence)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.