Skip to content

Instantly share code, notes, and snippets.

@stoneboyindc
Created September 12, 2019 17:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stoneboyindc/e98ebd1f000815ddfec6a70f07a438be to your computer and use it in GitHub Desktop.
Save stoneboyindc/e98ebd1f000815ddfec6a70f07a438be to your computer and use it in GitHub Desktop.
function nbYear(p0, percent, aug, P) {
// your code
var numYears = 0;
var currentPop = p0;
var convertPercent;
if (percent === null || percent == 0) {
convertPercent = 0;
} else {
convertPercent = percent * .01;
};
while (currentPop < P) {
currentPop = currentPop + (currentPop * convertPercent) + aug;
numYears += 1;
}
return numYears;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment