Question: Task 3: Triangular Numbers A triangular number is any number from the series of numbers (1, 3, 6, 10, 15, etc.) obtained by continued summation
Task 3: Triangular Numbers
A triangular number is any number from the series of numbers (1, 3, 6, 10, 15, etc.) obtained by continued summation of the natural numbers 1, 2, 3, 4, 5, etc.1 Implement a function next triangular number(num) that takes an integer and determines the smallest triangular number that is equal to or larger than the given number.
The function must:
take one argument: a positive integer, num
return trig num, where trig num is the smallest triangular number that is greater than or equal to num
use a while-loop
Example: calling next triangular number(25) returns 28 as the triangular number 21 (1+2+3+4+5+6 = 21) is smaller than 25, and so the next triangular number 28 (1 + 2 + 3 + 4 + 5 + 6 + 7 = 28), which is bigger than 25, is the next triangular number in the series.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
