Sep-11-2019, 04:36 PM
Hey guys, so I have been doing some basic tasks on while loops for loops which I completed with some help here and there and I mostly grasped it without too much headache.
The task I have now is proving a major challenge but I think its because I haven't really worked with it before and its my first nested loops assignment.
So, I need to use a nested for loop and create the following numbers pyramid as described below:
I understand that the rows will be defined with the outer loop and the columns with the inner loop.
And the code starts something like this I believe:
1
2 4
3 6 9
4 8 12 16
5 10 15 20 25
6 12 18 24 30 36
7 14 21 28 35 42 47
8 16 24 32 40 48 56 64
9 18 27 36 45 54 63 72 81
As yet I am just not getting it, I will really be for ever thankful if someone can give me guidance on this,
I do not want the code written for me, after all, I need to learn from this, I just need some pointers because this is driving me mad.
Thanks in advance
The task I have now is proving a major challenge but I think its because I haven't really worked with it before and its my first nested loops assignment.
So, I need to use a nested for loop and create the following numbers pyramid as described below:
I understand that the rows will be defined with the outer loop and the columns with the inner loop.
And the code starts something like this I believe:
for x in range(1,i+1):Here is what I need to create:
1
2 4
3 6 9
4 8 12 16
5 10 15 20 25
6 12 18 24 30 36
7 14 21 28 35 42 47
8 16 24 32 40 48 56 64
9 18 27 36 45 54 63 72 81
As yet I am just not getting it, I will really be for ever thankful if someone can give me guidance on this,
I do not want the code written for me, after all, I need to learn from this, I just need some pointers because this is driving me mad.
Thanks in advance