Assignment 11 - Multiplication Table
You can download this homework and set the permissions
with the commands
cd ~/public_html
wget http://www.comp.nus.edu.sg/~gem1501/assignment11.html
chmod 755 *.html
- General Outline
Children learn the multiplication table for the system based on
10 at school. Such a table can of course be produced in the
system based on any number being at least 2. Here an example
for the multiplication table of the system based on 13.
Note that the letters A,B,C are used for the missing digits.
Entry 0 1 2 3 4 5 6 7 8 9 A B C
0 times 0 0 0 0 0 0 0 0 0 0 0 0 0
1 times 0 1 2 3 4 5 6 7 8 9 A B C
2 times 0 2 4 6 8 A C 11 13 15 17 19 1B
3 times 0 3 6 9 C 12 15 18 1B 21 24 27 2A
4 times 0 4 8 C 13 17 1B 22 26 2A 31 35 39
5 times 0 5 A 12 17 1C 24 29 31 36 3B 43 48
6 times 0 6 C 15 1B 24 2A 33 39 42 48 51 57
7 times 0 7 11 18 22 29 33 3A 44 4B 55 5C 66
8 times 0 8 13 1B 26 31 39 44 4C 57 62 6A 75
9 times 0 9 15 21 2A 36 42 4B 57 63 6C 78 84
A times 0 A 17 24 31 3B 48 55 62 6C 79 86 93
B times 0 B 19 27 35 43 51 5C 6A 78 86 94 A2
C times 0 C 1B 2A 39 48 57 66 75 84 93 A2 B1
The task is to write a program that computes the multiplication
table for any given base between 2 and 36. This homework contains
a predefined program to compute the multiplication table for the base 10
and the task is to implement the same program for other bases then the
usual one. Note that the letters "A,B,C,..." are used for expressing
digits beyond "0,1,2,...,9" whenever the base requires more digits
than the usual ten. For more information on number systems and bases,
please see the corresponding
Wikipedia
page.
- Make multiplication table of variable size
Introduce a variable "base" for the multiplication which is
obtained from the user by the command
base = prompt("Enter Base of Numbering System");
Change the loop boundaries and other places which refer to the decimal
system adequately. Furthermore, take care that the sides of the
multiplication table are also output in the system for the chosen base.
Also, replace the 10 in the loop to compute the digit in the fields
"ones" and "tens" by the value of base and make the two arrays to be
two-dimensional arrays of size "base times base".
- Addition Table
Add an addition table to be calculated and printed
after the multiplication table for the same base.
Java Script Program starts here.
Java Script Program ends here.