// For C language
#include <stdio.h>
int main()
{
int i=0, a=0, t[20]; //use _t[20]_ for example if you need 20 element
while(i<20) //use _i<20_ for example if you need 20 element
{
if(!(a%2)) //here you can set the "by 2s" part, _if(!(a%3))_ is for "by 3" etc. [you can write _if((a%2)==0)_ instead of _if(!(a%2))_ aswell]
{
t[i]=a; //here you load into the t[] array on (i)th index the actual value (a) that is OK for your criterion (above if part); now t[0]=0 t[1]=2 t[2]=4 etc.
printf("%d\n",t[i]); //not needed, just for checking in terminal
i++; //here you increment the (i) index, this cause t[0] t[1] t[2] etc (not overloading into one index every value, just step it forward in the array)
}
a++; //here you increment the value to get bigger and bigger numbers
}
return 0;
}