Question: JavaScript question. If you were to arrange 15 dots in the shape of a triangle, you end up with an arrangement that might look something

JavaScript question. If you were to arrange 15 dots in the shape of a triangle, you end up with an arrangement that might look something like this:

0

0 0

0 0 0

0 0 0 0

0 0 0 0 0

The first row of the triangle contains one dot, the second row contains two dots then three and so on. the number of dots it takes to form a triangle containing n rows is the sum of the integers from 1 through n. This sum is known as a triangular number. If you start at 1, the fourth triangular number is the sum of the consecutive integers 1 through 4 ( 1 + 2 + 3 + 4), or 10. A triangular number can also be generated by the formula:

triangularNumber = n * ( n + 1) / 2

for any integer value of n. For example, the 10th triangular number, 55, can be generated by substituting 10 as the value for n in the preceding formula. create a program that generates a table of triangular numbers using the preceding formula. Have the program generate every fifth triangular number between 5 and 50 (that is, 5, 10, 15, ..., 50)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!