So I've been doing homework and accidentally came up with this loop
k = 0;
for (int i = 0; i < 100; ++i)
k += i;
So basically keep adding an incremented value of i to the total beginning from zero. And all of a sudden I get a sequence that looks like a parabola when graphed. With some weird coefficient something like
What gives? I googled this sequence and it turned out to be
1, 3, 6, 10, 15, 21, 28, 36, 45, ...
the triangular number sequence.
First of all, the generating function for it is given as:
which has nothing to do with my simple loop
k += i
and if this loop generates the same sequence, can I add it to the wiki article??
And secondly, why is it a parabola? and what is up with this weird coefficient???
k = 0;
for (int i = 0; i < 100; ++i)
k += i;
So basically keep adding an incremented value of i to the total beginning from zero. And all of a sudden I get a sequence that looks like a parabola when graphed. With some weird coefficient something like
What gives? I googled this sequence and it turned out to be
1, 3, 6, 10, 15, 21, 28, 36, 45, ...
the triangular number sequence.
First of all, the generating function for it is given as:
which has nothing to do with my simple loop
k += i
and if this loop generates the same sequence, can I add it to the wiki article??
And secondly, why is it a parabola? and what is up with this weird coefficient???
