[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 278
  • Last Modified:

until loop for population

Ok, Mexico's population is 58 million and is growing at annual rate of %7. US population is 260 million at annual rate of %2. How many years will Mexico's be greater than 1/2 of the US? This is what I have so far:

M := 58,000,000
US := 260,000,000
yrs := yrs + 1
  repeat
    M := 58,000,000 * 0.07
    US := 260,000,000 * 0.02
    yrs := yrs + 1
  until M > 1/2 US
0
kazooie21
Asked:
kazooie21
1 Solution
 
lama72phlCommented:
That's elementary algebra.
Here's the code:


begin
        M:=58,000,000;
        U:= 260,000,000 ;
        years_elapsed:=0;
        repeat
                   inc(years_elapsed);
                   M:=M*1.07;
                   U:=U*1.02;
        until M/U >0.5;
        writeln(' Mexico's pop will be greater than half of US in ' ,                       years_elapsed,' years');
end;
0
 
ozoCommented:
Is this a homweork assignment?
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now