Question: 2. Define a stacked number to be a number that is the sum of the first n positive integers for some n. The first

2. Define a stacked number to be a number that is the

2. Define a stacked number to be a number that is the sum of the first n positive integers for some n. The first 5 stacked numbers are 1=1 3 =1+2 6 = 1+2+3 10 = 1+2 +3+ 4 15 = 1+2+3+4 + 5 Note that from the above we can deduce that 7, 8. and 9 are not stacked numbers because they cannot be the sum of any sequence of positive integers that start at 1. Write a function named isStacked that returns 1 if its argument is stacked. Otherwise it returns 0. So for example, isStacked(10) should return 1 and isStacked(7) should return 0.

Step by Step Solution

3.50 Rating (153 Votes )

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 Programming Questions!