clear

fprintf ( '\n' );
fprintf ( 'Question 1:\n' );
fprintf ( '\n' );

  for i = 1 : 5
    if ( i == 1 )
      a = 1;
    else
      a = 2 * a + 1;
    end
    fprintf ( '%d\n', a );
  end

fprintf ( 'Press RETURN:' );
pause
clear

fprintf ( '\n' );
fprintf ( 'Question 2:\n' );
fprintf ( '\n' );

  i = 0;
  while ( i <= 10 )
    i = i + 1;
    b = i + 1;
  end
  fprintf ( 'i = %d, b = %d\n', i, b );

fprintf ( 'Press RETURN:' );
pause
clear

fprintf ( '\n' );
fprintf ( 'Question 3:\n' );
fprintf ( '\n' );

  c = 2;
  for k = 2 : 6
    c = c + k;
  end
  fprintf ( 'c = %d\n', c );

fprintf ( 'Press RETURN:' );
pause
clear

fprintf ( '\n' );
fprintf ( 'Question 4:\n' );
fprintf ( '\n' );

  e = 7;
  if ( e < 10 )
    e = e + 5;
  else
    e = e - 5;
  end
  if ( e > 10 )
    e = 2 * e;
  end

  fprintf ( 'e = %d\n', e );

fprintf ( 'Press RETURN:' );
pause
clear

fprintf ( '\n' );
fprintf ( 'Question 5:\n' );
fprintf ( '\n' );

  e = 10;
  f = -6;
  if ( f < 0 )
    e = - e;
    f = - f;
  end
  g = gcd ( e, f );
  e = e / g;
  f = f / g;

  fprintf ( 'e = %d, f = %d, g = %d\n', e, f, g );

fprintf ( 'Press RETURN:' );
pause
clear

fprintf ( '\n' );
fprintf ( 'Question 6:\n' );
fprintf ( '\n' );

  e = 1;
  f = 2;
  g = 3;
  e = e + g;
  f = e + g;
  g = e + g;

  fprintf ( 'e = %d, f = %d, g = %d\n', e, f, g );

fprintf ( 'Press RETURN:' );
pause
clear

fprintf ( '\n' );
fprintf ( 'Question 7:\n' );
fprintf ( '\n' );

  h = 0;
  for i = 1 : 3
    for j = 1 : i
      h = h + 1;
    end
  end

  fprintf ( 'h = %d\n', h );

fprintf ( 'Press RETURN:' );
pause
clear

fprintf ( '\n' );
fprintf ( 'Question 8:\n' );
fprintf ( '\n' );

  d = 10;
  while ( true )
    d = d + 2;
    if ( mod ( d, 9 ) == 0 )
      break;
    end
    d = d + 1;
  end

  fprintf ( 'd = %d\n', d );

fprintf ( 'Press RETURN:' );
pause
clear

fprintf ( '\n' );
fprintf ( 'Question 9:\n' );
fprintf ( '\n' );

  for i = 1 : 5
    if ( i == 1 )
      d = 1;
    elseif ( i == 2 )
      dold = d;
      d = 0;
    else
      dolder = dold;
      dold = d;
      d = ( i - 2 ) * ( dold + dolder );
    end
    fprintf ( '%d\n', d );
  end

fprintf ( 'Press RETURN:' );
pause
clear

fprintf ( '\n' );
fprintf ( 'Question 10:\n' );
fprintf ( '\n' );

  a = 15;
  b = 9;
  while ( 0 < b )
    r = mod ( a, b );
    a = b;
    b = r;
  end

  fprintf ( 'a = %d, b = %d\n', a, b );
