AP Computer Science :: Projects :: Pyramid Scheme
Problem
Write a method to calculate how many people would be necessary to raise a given amount of money in a pyramid scheme. Each person invites a given number of people until the last group of people are donating a dollar. Consider the example below where you are trying to raise $10 and each person invites 2 additional people:
$10 $5 $5 $2 $2 $2 $2 $1 $1 $1 $1 $1 $1 $1 $1
In this example, it would take 15 people to raise $10 if each person invites 2 additional people. Notice that we are using integers so we will ignore issues with integer division.
Instructions
- Download this project to start.
- Complete the fundraise method so it returns the number of people needed to raise the desired amount of money.
- Don't worry about integer division. The method can stop when the last people are donating $1.
- RIght-click on the unit test when you are done to test your work. You will need to make your own unit test as well.