Write a program that predicts the approximate size of a population of organisms. Use the following data:
- Initial number of organisms: 2
- Average daily growth: 30%
- Number of days to multiply: 10
The program should display the following data table:
Day Approiximate Population 1 2 2 2.6 3 3.38 4 4.39 5 5.71 6 7.42 7 9.65 8 12.54 9 16.31 10 21.20
My code does not output the same approximate population. Where am I wrong? Here is my code:
var NumOfOrganisms = 2; var DailyIncrease = .30; var NumOfDays; for(NumOfDays = 1; NumOfDays <= 10; NumOfDays++){ calculation(NumOfOrganisms, DailyIncrease, NumOfDays); } function calculation(organisms, increase, days){ var calculation = (organisms * increase) + days; console.log("increase is " + calculation); }
source share