SequenceList
Returns a list with an arithmetic sequence of integers.
Syntax
-
SequenceList(n)-
nis a positive integer
-
-
SequenceList(a, b[, d])-
aandbare integers -
dis a positive integer
-
Description
If n is a positive integer, then SequenceList(n) returns the list containing the first n positive numbers in order.
If a and b are integers, then SequenceList(a, b) returns the list containing all integers from a to b (inclusively) in order. If b < a, the sequence is decreasing. SequenceList(a, b, k) returns the integers from a to b with step k, that is, the integers a, a ± k, a ± 2k, ... in the direction of b but never exceeding b.
Examples
SequenceList is often used to generate arbitrary sequences by means of the @ operator and function objects:
SequenceList(10) @ sqr
1 4 9 16 25 36 49 64 81 100
SequenceList(10) @ prime
2 3 5 7 11 13 17 19 23 29
SequenceList(10) @ (n ↦ 2⋅n^2 − 1)
1 7 17 31 49 71 97 127 161 199
ℙ ≔ SequenceList(1000000) @ prime;
count(ℙ, p ↦ ∑(digits(p)) = 10)
1121
Another approach is to use the compute function:
compute(n!, n, 1, 10)
1 2 6 24 120 720 5040 40320 362880 3628800