CHALLENGE - Triangular Numbers | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

CHALLENGE - Triangular Numbers

Triangular numbers are a math series that represent the number of points in a triangle, for example the number of bowling pins. The first number is 1. The next row would have 2 for a total of 3. The next row would have 3 for a total of 6. https://en.m.wikipedia.org/wiki/Triangular_number The challenge is to write a program to return the nth triangular number based on user input. For an additional challenge, print a diagram of the triangle with the number in each row represented by "X"s! Good luck!

21st Feb 2018, 3:28 AM
Adam Schmitt
Adam Schmitt - avatar
5 Answers
+ 4
I couldn't make a nice tree with these numbers.. https://code.sololearn.com/chM4I4m8fUO5
21st Feb 2018, 4:37 AM
Colin
Colin - avatar
+ 4
Kindly post this as an assignment, as then it will gather a larger number of submissions. You will get a lesson creator badge for 10 such assignments, along with some XP. Just open Lesson Factory and give it a shot!
21st Feb 2018, 4:54 AM
Kinshuk Vasisht
Kinshuk Vasisht - avatar
+ 4
Made code in the train on my way to work: https://code.sololearn.com/c2LwfKJPcoyX/?ref=app
21st Feb 2018, 5:10 AM
Paul
Paul - avatar
+ 3
https://code.sololearn.com/c5IbQo408TOt/?ref=app https://code.sololearn.com/c1N07Cf4HpNn/?ref=app
21st Feb 2018, 8:25 AM
Вадим Сухотин (Vadim Sukhotin)
Вадим Сухотин (Vadim Sukhotin) - avatar
+ 1
print(n*(n+1)/2)
21st Feb 2018, 5:47 PM
VcC
VcC - avatar