% mexico_population_sequence.m
%  Model Mexico population from 1950 to YEAR_END, with a given
%  annual growth RATE.
%
%  Year  Population
%  1950  25,791,017
%  1960  34,923,129
%  1970  48,225,238
%  1980  66,846,833
%  1990  81,249,645
%  2000  97,483,412
%  2010 113,580,528
%
rate = input ( '  Enter model growth rate, like 0.03: ' );
year_end = input ( '  What year after 1950 should model stop at: ' );

year_start = 1950;

for year = year_start : year_end

  if ( year == year_start )
    pop = 25791017;
  else
    pop_old = pop;
    pop = ( 1.0 + rate ) * pop_old;
  end

  fprintf ( '  %d  %d\n', year, round ( pop ) )
end
    
