Skip to content

Instantly share code, notes, and snippets.

@zetashift
Created February 25, 2018 05:24
Show Gist options
  • Save zetashift/9a7a009c58bfcc852c90446d4329e38a to your computer and use it in GitHub Desktop.
Save zetashift/9a7a009c58bfcc852c90446d4329e38a to your computer and use it in GitHub Desktop.
Growth of Population
proc nbYear*(p0: int, percent: float64, aug: int, p: int): int =
var count = 0
var pop = p0
while pop != p:
count = count + 1
pop = pop + p0 * (percent / 100.float).int + aug
return count
echo(nbYear(1000, 5, 50, 2000))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment