2 Oct 2018: Multiplication Tables
Instructions
-
Create a function that takes two integers (a factor and a count), and returns nothing.
-
The function should contain a
for()
loop that iteratescount
times. -
Each time through the loop, the function should:
-
Compute the next multiple of factor
-
Output the result
-
-
Example:
-
multiples(5,3); // Output: 1 times 5 is 5; 2 times 5 is 10; 3 times 5 is 15;
-
Create a
for()
loop inmain()
that calls your function for factors ranging from 1 to 7.
Challenge Problem
-
10 points Extra Credit (Due 5pm Fri).
-
-
(4 points) Modify the above function to take one integer, and test all possible divisors.
-
Return
true
if the integer is prime, andfalse
otherwise.
-
-
(2 points) Edit your function so that it tests no more divisors than necessary.
-
(3 points) Modify the multiplication table
for()
loop to:-
Use your modified function
-
Identify all prime numbers between 1 and 200
-
-
(1 point) The final output of your program should state the total number of primes less than 200 (excluding 1).
-