I've come across a problem that asks me to print a table to visualize all factors of each integer ranging from 1
to limit
. Then it specifies that a given position i
, starting from 1
in a row n
, then a *
indicates that i
is a factor of n
, and -
indicates that it is not. Below is an example of the output.
I know that I've to make use modulus operator to test the factors and a for loop, but I'm so confused with constructing the code.
Maximum number to factorise: 20
* - - - - - - - - - - - - - - - - - - -
* * - - - - - - - - - - - - - - - - - -
* - * - - - - - - - - - - - - - - - - -
* * - * - - - - - - - - - - - - - - - -
* - - - * - - - - - - - - - - - - - - -
* * * - - * - - - - - - - - - - - - - -
* - - - - - * - - - - - - - - - - - - -
* * - * - - - * - - - - - - - - - - - -
* - * - - - - - * - - - - - - - - - - -
* * - - * - - - - * - - - - - - - - - -
* - - - - - - - - - * - - - - - - - - -
* * * * - * - - - - - * - - - - - - - -
* - - - - - - - - - - - * - - - - - - -
* * - - - - * - - - - - - * - - - - - -
* - * - * - - - - - - - - - * - - - - -
* * - * - - - * - - - - - - - * - - - -
* - - - - - - - - - - - - - - - * - - -
* * * - - * - - * - - - - - - - - * - -
* - - - - - - - - - - - - - - - - - * -
* * - * * - - - - * - - - - - - - - - *