I'm writing some while loops but I feel like there is a better way to write them.

```
int i=3;
while (i<31)
{
cout << i << " ";
i+=3;
} //this one is for the first 10 terms of a sequence starting with 3 and adding 3 each time.
int i=2;
while (i<50000)
{
cout << i << " ";
i*=2;
} //this one is the first 15 terms starting at 2 and doubling each one.
```

Is there some way to let the program know how many variables to show without figuring out how far it has to go? Also, what if I wanted to write a loop where each number is subtracted by one more than the one before it (100, 99, 97, 94, 90...)?