python - What is a clearer way to generate this sequence of numbers? -


I have to prepare a list like this:

  [0, 2, 6, 12, 20, 30, 42, 56, 72, 90]  

And this is my current code

  g = lambda x: x + g ( X - 2) If x & gt; 0 and 0 print (for i in the category of [g (2 * i)) (10)]  

What is a clear and more direct way to generate the sequence?

These are some of the first things that appear, a number that is the product of two consecutive integers N * (n + 1)

sequence

I found it in search. It is easy to generate them with the understanding of the list:

  gt; & Gt; [0, 2, 6, 12, 20, 30, 42, 56, 72, 90]  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -