I'm supposed to generate a sequence of even numbers from $1$ to $100$ in Maple. While this should be very straightforward, I've tried using both a conditional statement within the $\text{seq}()$ command as well as a loop but got an error in both cases. I've looked at the structure for the loop and can't quite determine where my syntax is incorrect.
2026-03-27 12:01:39.1774612899
On
How to generate a sequence in maple based on a condition
1.9k Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail At
2
There are 2 best solutions below
2
On
You ought to prefer Adriano's answer.
However you seem to be learning Maple, and you did mention that you were unable to get a conditional to work within a call to the seq command. So I'll mention that can be done by using the so-called operator form of if.
seq( `if`( i::even, i, NULL ), i=1..100 );
seq( `if`( irem(i,2)=0, i, NULL ), i=1..100 );
Note that your question is about only programming in Maple rather than doing math in Maple, and so is off-topic in this forum. More appropriate would be www.stackoverflow.com or www.mapleprimes.com .
Try one of the following: