2 Oct 2018: Multiplication Tables

Instructions

  1. Create a function that takes two integers (a factor and a count), and returns nothing.

    1. The function should contain a for() loop that iterates count times.

    2. Each time through the loop, the function should:

      1. Compute the next multiple of factor

      2. Output the result

    3. Example:

multiples(5,3);
// Output:
1 times 5 is 5;
2 times 5 is 10;
3 times 5 is 15;
  1. Create a for() loop in main() that calls your function for factors ranging from 1 to 7.

Challenge Problem

  • 10 points Extra Credit (Due 5pm Fri).

  • Submission Form

    1. (4 points) Modify the above function to take one integer, and test all possible divisors.

      • Return true if the integer is prime, and false otherwise.

    2. (2 points) Edit your function so that it tests no more divisors than necessary.

    3. (3 points) Modify the multiplication table for() loop to:

      • Use your modified function

      • Identify all prime numbers between 1 and 200

    4. (1 point) The final output of your program should state the total number of primes less than 200 (excluding 1).