DEV Community

Discussion on: Daily Challenge #120 - Growth of a Population

Collapse
 
udiudi profile image
Udi

Ruby

def nb_year(p0, percent, aug, p)
  actual_percent = percent.to_f / 100
  year = 0

  while p >= p0
    year += 1
    p0 += p0 * actual_percent + aug
  end

  year
end