Ex:(int b = 1; b < 5; b++)
How to have(write) :
Multiply each other elements in loop like : 1234 And " b * ( each element of loop)" like : 1(1+2+3+4) …Pls I’m a beginer
Ex:(int b = 1; b < 5; b++)
How to have(write) :
Multiply each other elements in loop like : 1234 And " b * ( each element of loop)" like : 1(1+2+3+4) …Pls I’m a beginer
I am not sure I really understand the question… but if the following answer is wrong, could you please clarify?
From what I understand, you are trying to have a loop that multiplies the sum of every index the loop will handle. So if you have:
for (int i = 1; i<5; i++)
{
...
}
you will want to get:
If this is right, then this is how you can do it:
int b = 5;
int c = 0;
for (int i = 1; i<b; i++)
{
c += i;
}
for (int i = 1; i<b; i++)
{
print(i*c);
}
If, however, you are not trying to get a result but an expression ( “1(1+2+3+4)” instead of 10 ) then this is how you would do it:
int b = 5;
string c = "1";
for (int i = 2; i<b; i++)
{
c+= "+" + i;
}
for (int i = 1; i<b; i++)
{
print( i + "(" + c + ")" );
}
Hope this helps