Multiplication tables: Difference between revisions

m
m (syntax highlighting fixup automation)
m (→‎{{header|Wren}}: Minor tidy)
 
(19 intermediate revisions by 12 users not shown)
Line 1,249:
11 | 121 132
12 | 144</pre>
 
=={{header|ASIC}}==
{{trans|Modula-2}}
<syntaxhighlight lang="basic">
REM Multiplication tables
N = 12
PREDN = N - 1
WDTH = 3
CLS
FOR J = 1 TO PREDN
INTVAL = J
GOSUB PRINTINT:
PRINT " ";
NEXT J
INTVAL = N
GOSUB PRINTINT:
PRINT
FOR J = 0 TO PREDN
PRINT "----";
NEXT J
PRINT "+"
FOR I = 1 TO N
WDTH = 3
FOR J = 1 TO N
IF J < I THEN
PRINT " ";
ELSE
INTVAL = I * J
GOSUB PRINTINT:
PRINT " ";
ENDIF
NEXT J
PRINT "| ";
INTVAL = I
WDTH = 2
GOSUB PRINTINT:
PRINT
NEXT I
END
 
PRINTINT:
REM Writes the value of INTVAL in a field of the given WDTH
S2$ = STR$(INTVAL)
S2$ = LTRIM$(S2$)
SPNUM = LEN(S2$)
SPNUM = WDTH - SPNUM
S1$ = SPACE$(SPNUM)
PRINT S1$;
PRINT S2$;
RETURN
</syntaxhighlight>
{{out}}
<pre>
1 2 3 4 5 6 7 8 9 10 11 12
------------------------------------------------+
1 2 3 4 5 6 7 8 9 10 11 12 | 1
4 6 8 10 12 14 16 18 20 22 24 | 2
9 12 15 18 21 24 27 30 33 36 | 3
16 20 24 28 32 36 40 44 48 | 4
25 30 35 40 45 50 55 60 | 5
36 42 48 54 60 66 72 | 6
49 56 63 70 77 84 | 7
64 72 80 88 96 | 8
81 90 99 108 | 9
100 110 120 | 10
121 132 | 11
144 | 12
</pre>
 
=={{header|AutoHotkey}}==
Line 1,457 ⟶ 1,389:
 
=={{header|BASIC}}==
 
 
==={{header|Applesoft BASIC}}===
<syntaxhighlight lang="applesoftbasic">100 M = 12
Line 1,470 ⟶ 1,400:
180 PRINT TAB(FN T(J)) MID$(" ", 1, 3 - LEN(V$) - (J < 4)) V$;
190 NEXT J, N</syntaxhighlight>
 
==={{header|ASIC}}===
{{trans|Modula-2}}
<syntaxhighlight lang="basic">
REM Multiplication tables
N = 12
PREDN = N - 1
WDTH = 3
CLS
FOR J = 1 TO PREDN
INTVAL = J
GOSUB PRINTINT:
PRINT " ";
NEXT J
INTVAL = N
GOSUB PRINTINT:
PRINT
FOR J = 0 TO PREDN
PRINT "----";
NEXT J
PRINT "+"
FOR I = 1 TO N
WDTH = 3
FOR J = 1 TO N
IF J < I THEN
PRINT " ";
ELSE
INTVAL = I * J
GOSUB PRINTINT:
PRINT " ";
ENDIF
NEXT J
PRINT "| ";
INTVAL = I
WDTH = 2
GOSUB PRINTINT:
PRINT
NEXT I
END
 
PRINTINT:
REM Writes the value of INTVAL in a field of the given WDTH
S2$ = STR$(INTVAL)
S2$ = LTRIM$(S2$)
SPNUM = LEN(S2$)
SPNUM = WDTH - SPNUM
S1$ = SPACE$(SPNUM)
PRINT S1$;
PRINT S2$;
RETURN
</syntaxhighlight>
{{out}}
<pre>
1 2 3 4 5 6 7 8 9 10 11 12
------------------------------------------------+
1 2 3 4 5 6 7 8 9 10 11 12 | 1
4 6 8 10 12 14 16 18 20 22 24 | 2
9 12 15 18 21 24 27 30 33 36 | 3
16 20 24 28 32 36 40 44 48 | 4
25 30 35 40 45 50 55 60 | 5
36 42 48 54 60 66 72 | 6
49 56 63 70 77 84 | 7
64 72 80 88 96 | 8
81 90 99 108 | 9
100 110 120 | 10
121 132 | 11
144 | 12
</pre>
 
==={{header|BASIC256}}===
Line 1,513 ⟶ 1,511:
11 121 132
12 144</pre>
 
==={{header|Chipmunk Basic}}===
{{works with|Chipmunk Basic|3.6.4}}
{{trans|IS-BASIC}}
<syntaxhighlight lang="qbasic">100 cls
110 print tab (4);
120 for i = 1 to 12
130 print using " ###";i;
140 next
150 print
160 print " --+------------------------------------------------"
170 for i = 1 to 12
180 print using " ##|";i;
190 print tab (i*4);
200 for j = i to 12
210 print using " ###";i*j;
220 next
230 print
240 next
250 end</syntaxhighlight>
 
==={{header|Commodore BASIC}}===
Line 1,632 ⟶ 1,650:
 
==={{header|FutureBasic}}===
<syntaxhighlight lang="basic">
long i, j
 
Line 1,656 ⟶ 1,674:
<pre>
| 1 2 3 4 5 6 7 8 9 10 11 12
---+------------------------------------------------
1| 1 2 3 4 5 6 7 8 9 10 11 12
2| 4 6 8 10 12 14 16 18 20 22 24
3| 9 12 15 18 21 24 27 30 33 36
4| 16 20 24 28 32 36 40 44 48
5| 25 30 35 40 45 50 55 60
6| 36 42 48 54 60 66 72
7| 49 56 63 70 77 84
8| 64 72 80 88 96
9| 81 90 99 108
10| 100 110 120
11| 121 132
12| 144
</pre>
 
==={{header|Gambas}}===
'''[https://gambas-playground.proko.eu/?gist=3a3a987766a9a9a383b3e0e8a65d9ea2 Click this link to run this code]'''
<syntaxhighlight lang="gambas">'Code 'stolen' from Free Basic and altered to work in Gambas
 
Public Sub Main()
Dim i, j As Integer
 
Print " X|";
For i = 1 To 12
Print Format(i, "####");
Next
Print
Print "---+"; String(48, "-")
For i = 1 To 12
Print Format(i, "###");
Print "|"; Space(4 * (i - 1));
For j = i To 12
Print Format(i * j, "####");
Next
Print
Next
 
End</syntaxhighlight>
Output:
<pre>
X| 1 2 3 4 5 6 7 8 9 10 11 12
---+------------------------------------------------
1| 1 2 3 4 5 6 7 8 9 10 11 12
Line 1,673 ⟶ 1,734:
==={{header|GW-BASIC}}===
{{trans|Modula-2}}
{{works with|BASICA}}
{{works with|PC-BASIC|any}}
<syntaxhighlight lang="qbasicgwbasic">
10 ' Multiplication Tables
20 LET N% = 12
Line 1,911 ⟶ 1,973:
</syntaxhighlight>Output:
<TABLE border=1 ><TR bgcolor=silver align=center><TD><TD>1<TD>2<TD>3<TD>4<TD>5<TD>6<TD>7<TD>8<TD>9<TD>10<TD>11<TD>12</td></TR><TR align=right><TD>1</td><td width=25>1</td><td width=25>2</td><td width=25>3</td><td width=25>4</td><td width=25>5</td><td width=25>6</td><td width=25>7</td><td width=25>8</td><td width=25>9</td><td width=25>10</td><td width=25>11</td><td width=25>12</td><TR align=right><TD>2</td><td width=25></td><td width=25>4</td><td width=25>6</td><td width=25>8</td><td width=25>10</td><td width=25>12</td><td width=25>14</td><td width=25>16</td><td width=25>18</td><td width=25>20</td><td width=25>22</td><td width=25>24</td><TR align=right><TD>3</td><td width=25></td><td width=25></td><td width=25>9</td><td width=25>12</td><td width=25>15</td><td width=25>18</td><td width=25>21</td><td width=25>24</td><td width=25>27</td><td width=25>30</td><td width=25>33</td><td width=25>36</td><TR align=right><TD>4</td><td width=25></td><td width=25></td><td width=25></td><td width=25>16</td><td width=25>20</td><td width=25>24</td><td width=25>28</td><td width=25>32</td><td width=25>36</td><td width=25>40</td><td width=25>44</td><td width=25>48</td><TR align=right><TD>5</td><td width=25></td><td width=25></td><td width=25></td><td width=25></td><td width=25>25</td><td width=25>30</td><td width=25>35</td><td width=25>40</td><td width=25>45</td><td width=25>50</td><td width=25>55</td><td width=25>60</td><TR align=right><TD>6</td><td width=25></td><td width=25></td><td width=25></td><td width=25></td><td width=25></td><td width=25>36</td><td width=25>42</td><td width=25>48</td><td width=25>54</td><td width=25>60</td><td width=25>66</td><td width=25>72</td><TR align=right><TD>7</td><td width=25></td><td width=25></td><td width=25></td><td width=25></td><td width=25></td><td width=25></td><td width=25>49</td><td width=25>56</td><td width=25>63</td><td width=25>70</td><td width=25>77</td><td width=25>84</td><TR align=right><TD>8</td><td width=25></td><td width=25></td><td width=25></td><td width=25></td><td width=25></td><td width=25></td><td width=25></td><td width=25>64</td><td width=25>72</td><td width=25>80</td><td width=25>88</td><td width=25>96</td><TR align=right><TD>9</td><td width=25></td><td width=25></td><td width=25></td><td width=25></td><td width=25></td><td width=25></td><td width=25></td><td width=25></td><td width=25>81</td><td width=25>90</td><td width=25>99</td><td width=25>108</td><TR align=right><TD>10</td><td width=25></td><td width=25></td><td width=25></td><td width=25></td><td width=25></td><td width=25></td><td width=25></td><td width=25></td><td width=25></td><td width=25>100</td><td width=25>110</td><td width=25>120</td><TR align=right><TD>11</td><td width=25></td><td width=25></td><td width=25></td><td width=25></td><td width=25></td><td width=25></td><td width=25></td><td width=25></td><td width=25></td><td width=25></td><td width=25>121</td><td width=25>132</td><TR align=right><TD>12</td><td width=25></td><td width=25></td><td width=25></td><td width=25></td><td width=25></td><td width=25></td><td width=25></td><td width=25></td><td width=25></td><td width=25></td><td width=25></td><td width=25>144</td></table>
 
=== {{header|Tiny BASIC}} ===
{{trans|Modula-2}}
{{works with|TinyBasic}}
<syntaxhighlight lang="basic">
10 REM MULTIPLICATION TABLES
20 LET N=12
30 REM TO ALIGN NUMBERS TO THE RIGHT
40 REM ASSUME THAT N IS AT MOST TWO-DIGIT.
50 LET J=1
60 PRINT " ";
70 IF J<10 THEN PRINT " ";
80 PRINT J;" ";
90 LET J=J+1
100 IF J=N THEN GOTO 120
110 GOTO 60
120 PRINT " ";
130 IF N<10 THEN PRINT " ";
140 PRINT N
150 LET J=0
160 PRINT "----";
170 J=J+1
180 IF J=N THEN GOTO 200
190 GOTO 160
200 PRINT "+"
210 LET I=1
220 LET J=1
230 IF J<I THEN GOTO 290
240 LET P=I*J
250 IF P<100 THEN PRINT " ";
260 IF P<10 THEN PRINT " ";
270 PRINT P;" ";
280 GOTO 300
290 PRINT " ";
300 IF J=N THEN GOTO 330
310 LET J=J+1
320 GOTO 230
330 PRINT "! ";
340 IF I<10 THEN PRINT " ";
350 PRINT I
360 IF I=N THEN GOTO 390
370 LET I=I+1
380 GOTO 220
390 END
</syntaxhighlight>
{{out}}
<pre>
1 2 3 4 5 6 7 8 9 10 11 12
------------------------------------------------+
1 2 3 4 5 6 7 8 9 10 11 12 ! 1
4 6 8 10 12 14 16 18 20 22 24 ! 2
9 12 15 18 21 24 27 30 33 36 ! 3
16 20 24 28 32 36 40 44 48 ! 4
25 30 35 40 45 50 55 60 ! 5
36 42 48 54 60 66 72 ! 6
49 56 63 70 77 84 ! 7
64 72 80 88 96 ! 8
81 90 99 108 ! 9
100 110 120 ! 10
121 132 ! 11
144 ! 12
</pre>
 
==={{header|True BASIC}}===
Line 1,933 ⟶ 2,057:
==={{header|uBasic/4tH}}===
{{trans|BBC BASIC}}
<syntaxhighlight lang="basic">For R = 1 To 12
Print R;Tab(R * 5);
For C = R To 12
Line 1,955 ⟶ 2,079:
 
0 OK, 0:105</pre>
 
==={{header|VBA}}===
<syntaxhighlight lang="vb">
Option Explicit
 
Sub Multiplication_Tables()
Dim strTemp As String, strBuff As String
Dim i&, j&, NbDigits As Byte
 
'You can adapt the following const :
Const NB_END As Byte = 12
 
Select Case NB_END
Case Is < 10: NbDigits = 3
Case 10 To 31: NbDigits = 4
Case 31 To 100: NbDigits = 5
Case Else: MsgBox "Number too large": Exit Sub
End Select
strBuff = String(NbDigits, " ")
For i = 1 To NB_END
strTemp = Right(strBuff & i, NbDigits)
For j = 2 To NB_END
If j < i Then
strTemp = strTemp & strBuff
Else
strTemp = strTemp & Right(strBuff & j * i, NbDigits)
End If
Next j
Debug.Print strTemp
Next i
End Sub
</syntaxhighlight>
{{out}}
<pre> 1 2 3 4 5 6 7 8 9 10 11 12
2 4 6 8 10 12 14 16 18 20 22 24
3 9 12 15 18 21 24 27 30 33 36
4 16 20 24 28 32 36 40 44 48
5 25 30 35 40 45 50 55 60
6 36 42 48 54 60 66 72
7 49 56 63 70 77 84
8 64 72 80 88 96
9 81 90 99 108
10 100 110 120
11 121 132
12 144</pre>
 
==={{header|Visual Basic}}===
Line 2,174 ⟶ 2,344:
•Out˘ Table 12</syntaxhighlight>
{{Out}}
<syntaxhighlightpre> | 1 2 3 4 5 6 7 8 9 10 11 12
--+-----------------------------------------------
1| 1 2 3 4 5 6 7 8 9 10 11 12
Line 2,187 ⟶ 2,357:
10| 100 110 120
11| 121 132
12| 144</syntaxhighlightpre>
 
=={{header|Bracmat}}==
Line 3,120 ⟶ 3,290:
=={{header|EasyLang}}==
 
<syntaxhighlight>n lang= 12"easylang">
n = 12
func out h . .
numfmt 0 4
if h < 10
write " "
elif h < 100
write " "
.
write " "
write h
.
write " "
for i = 1 to n
call outwrite i
.
print ""
write " "
for i = 1 to n
write "----"
.
print ""
for i = 1 to n
call outwrite i
write "|"
for j = 1 to n
if j < i
write " "
else
call out write i * j
.
.
print ""
.
.</syntaxhighlight>
</syntaxhighlight>
 
=={{header|EchoLisp}}==
Line 3,219 ⟶ 3,383:
11 | 121 132
12 | 144
</pre>
 
=={{header|EMal}}==
{{trans|TypeScript}}
<syntaxhighlight lang="emal">
int NUMBER = 12
for int j = 1; j <= NUMBER; ++j do write((text!j).padStart(3, " ") + " ") end
writeLine()
writeLine("----" * NUMBER + "+")
for int i = 1; i <= NUMBER; i++
for int j = 1; j <= NUMBER; ++j
write(when(j < i, " ", (text!(i * j)).padStart(3, " ") + " "))
end
writeLine("| " + (text!i).padStart(2, " "))
end
</syntaxhighlight>
{{out}}
<pre>
1 2 3 4 5 6 7 8 9 10 11 12
------------------------------------------------+
1 2 3 4 5 6 7 8 9 10 11 12 | 1
4 6 8 10 12 14 16 18 20 22 24 | 2
9 12 15 18 21 24 27 30 33 36 | 3
16 20 24 28 32 36 40 44 48 | 4
25 30 35 40 45 50 55 60 | 5
36 42 48 54 60 66 72 | 6
49 56 63 70 77 84 | 7
64 72 80 88 96 | 8
81 90 99 108 | 9
100 110 120 | 10
121 132 | 11
144 | 12
</pre>
 
Line 4,063 ⟶ 4,259:
C
END</syntaxhighlight>Inserting the following two lines before the inner DO loop will print the format specifier used to print each row of the table.<syntaxhighlight lang="fortran"> WRITE(1,4) (A(J), J = 1,24)
4 FORMAT(1x,24A1)</syntaxhighlight>Running the program produces the following output<syntaxhighlightpre>
| 1 2 3 4 5 6 7 8 9 10 11 12
--+------------------------------------------------
Line 4,077 ⟶ 4,273:
10| 100 110 120
11| 121 132
12| 144</syntaxhighlightpre>
 
=={{header|Frink}}==
Line 4,098 ⟶ 4,294:
11 121 132
12 144
</pre>
 
=={{header|Gambas}}==
'''[https://gambas-playground.proko.eu/?gist=3a3a987766a9a9a383b3e0e8a65d9ea2 Click this link to run this code]'''
<syntaxhighlight lang="gambas">'Code 'stolen' from Free Basic and altered to work in Gambas
 
Public Sub Main()
Dim i, j As Integer
 
Print " X|";
For i = 1 To 12
Print Format(i, "####");
Next
Print
Print "---+"; String(48, "-")
For i = 1 To 12
Print Format(i, "###");
Print "|"; Space(4 * (i - 1));
For j = i To 12
Print Format(i * j, "####");
Next
Print
Next
 
End</syntaxhighlight>
Output:
<pre>
X| 1 2 3 4 5 6 7 8 9 10 11 12
---+------------------------------------------------
1| 1 2 3 4 5 6 7 8 9 10 11 12
2| 4 6 8 10 12 14 16 18 20 22 24
3| 9 12 15 18 21 24 27 30 33 36
4| 16 20 24 28 32 36 40 44 48
5| 25 30 35 40 45 50 55 60
6| 36 42 48 54 60 66 72
7| 49 56 63 70 77 84
8| 64 72 80 88 96
9| 81 90 99 108
10| 100 110 120
11| 121 132
12| 144
</pre>
 
Line 4,395 ⟶ 4,548:
12 | 144 156
13 | 169 </pre>
 
=={{Header|Insitux}}==
<syntaxhighlight lang="insitux">
(var pad-num (comp str (pad-left " " 4)))
 
(join "\n"
(for y (range 1 13)
(... str "x" (pad-num y)
(for x (range 1 13)
(if (> y x)
" "
(pad-num (* x y)))))))
</syntaxhighlight>
{{out}}
<pre>
x 1 1 2 3 4 5 6 7 8 9 10 11 12
x 2 4 6 8 10 12 14 16 18 20 22 24
x 3 9 12 15 18 21 24 27 30 33 36
x 4 16 20 24 28 32 36 40 44 48
x 5 25 30 35 40 45 50 55 60
x 6 36 42 48 54 60 66 72
x 7 49 56 63 70 77 84
x 8 64 72 80 88 96
x 9 81 90 99 108
x 10 100 110 120
x 11 121 132
x 12 144
</pre>
 
=={{header|J}}==
Line 4,460 ⟶ 4,641:
=={{header|JavaScript}}==
 
===Imperative Unicode output ===
The following example works with any (modern) JavaScript runtime:
 
<syntaxhighlight lang="javascript" lines>
function timesTable(){
let output = "";
const size = 12;
for(let i = 1; i <= size; i++){
output += i.toString().padStart(3);
output += i !== size ? " " : "\n";
}
for(let i = 0; i <= size; i++)
output += i !== size ? "════" : "╕\n";
 
for(let i = 1; i <= size; i++){
for(let j = 1; j <= size; j++){
output += j < i
? " "
: (i * j).toString().padStart(3) + " ";
}
output += `│ ${i}\n`;
}
return output;
}
</syntaxhighlight>
 
{{out}}
<pre>
1 2 3 4 5 6 7 8 9 10 11 12
════════════════════════════════════════════════╕
1 2 3 4 5 6 7 8 9 10 11 12 │ 1
4 6 8 10 12 14 16 18 20 22 24 │ 2
9 12 15 18 21 24 27 30 33 36 │ 3
16 20 24 28 32 36 40 44 48 │ 4
25 30 35 40 45 50 55 60 │ 5
36 42 48 54 60 66 72 │ 6
49 56 63 70 77 84 │ 7
64 72 80 88 96 │ 8
81 90 99 108 │ 9
100 110 120 │ 10
121 132 │ 11
144 │ 12
</pre>
 
=== HTML tables ===
The following examples require a browser or browser-like environment:
 
====Imperative====
<syntaxhighlight lang="html4strict"><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<head>
Line 4,467 ⟶ 4,694:
<title>12 times table</title>
<script type='text/javascript'>
 
function multiplication_table(n, target) {
var table = document.createElement('table');
Line 4,502 ⟶ 4,728:
target.appendChild(table);
}
 
</script>
<style type='text/css'>
Line 4,518 ⟶ 4,743:
<div><table><tr><th>x</th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>8</th><th>9</th><th>10</th><th>11</th><th>12</th></tr><tr><th>1</th><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td><td>8</td><td>9</td><td>10</td><td>11</td><td>12</td></tr><tr><th>2</th><td> </td><td>4</td><td>6</td><td>8</td><td>10</td><td>12</td><td>14</td><td>16</td><td>18</td><td>20</td><td>22</td><td>24</td></tr><tr><th>3</th><td> </td><td> </td><td>9</td><td>12</td><td>15</td><td>18</td><td>21</td><td>24</td><td>27</td><td>30</td><td>33</td><td>36</td></tr><tr><th>4</th><td> </td><td> </td><td> </td><td>16</td><td>20</td><td>24</td><td>28</td><td>32</td><td>36</td><td>40</td><td>44</td><td>48</td></tr><tr><th>5</th><td> </td><td> </td><td> </td><td> </td><td>25</td><td>30</td><td>35</td><td>40</td><td>45</td><td>50</td><td>55</td><td>60</td></tr><tr><th>6</th><td> </td><td> </td><td> </td><td> </td><td> </td><td>36</td><td>42</td><td>48</td><td>54</td><td>60</td><td>66</td><td>72</td></tr><tr><th>7</th><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>49</td><td>56</td><td>63</td><td>70</td><td>77</td><td>84</td></tr><tr><th>8</th><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>64</td><td>72</td><td>80</td><td>88</td><td>96</td></tr><tr><th>9</th><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>81</td><td>90</td><td>99</td><td>108</td></tr><tr><th>10</th><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>100</td><td>110</td><td>120</td></tr><tr><th>11</th><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>121</td><td>132</td></tr><tr><th>12</th><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>144</td></tr></table></div>
 
====Functional====
=====ES5=====
<syntaxhighlight lang="javascript">(function (m, n) {
 
// [m..n]
function range(m, n) {
Line 4,533 ⟶ 4,758:
return [].concat.apply([], xs.map(f));
}
 
var rng = range(m, n),
lstTable = [['x'].concat( rng )]
.concat(mb(rng, function (x) {
return [[x].concat(mb(rng, function (y) {
return y < x ? [''] : [x * y]; // triangle only
}))]}));
Line 4,567 ⟶ 4,789:
// or simply stringified as JSON
JSON.stringify(lstTable);
})(1, 12);</syntaxhighlight>
 
Line 4,615 ⟶ 4,836:
[12,"","","","","","","","","","","",144]]</syntaxhighlight>
 
=====ES6=====
<syntaxhighlight lang="javascript">(() => {
"use strict";
Line 4,719 ⟶ 4,940:
|}
 
=={{header|jq}}==
<syntaxhighlight lang="jq">
def lpad($len): tostring | ($len - length) as $l | (" " * $l)[:$l] + .;
 
def multiplication($n):
($n*$n|tostring|length) as $len
| ["x", range(0; $n + 1)] | map(lpad($len)) | join(" "),
(["", range(0; $n + 1)] | map($len*"-") | join(" ")),
( range(0; $n + 1) as $i
| [$i,
range(0; $n + 1) as $j
| if $j>=$i then $i*$j else "" end]
| map(lpad($len))
| join(" ") ) ;
 
multiplication(12)
</syntaxhighlight>
{{output}}
<pre>
x 0 1 2 3 4 5 6 7 8 9 10 11 12
--- --- --- --- --- --- --- --- --- --- --- --- --- ---
0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 1 2 3 4 5 6 7 8 9 10 11 12
2 4 6 8 10 12 14 16 18 20 22 24
3 9 12 15 18 21 24 27 30 33 36
4 16 20 24 28 32 36 40 44 48
5 25 30 35 40 45 50 55 60
6 36 42 48 54 60 66 72
7 49 56 63 70 77 84
8 64 72 80 88 96
9 81 90 99 108
10 100 110 120
11 121 132
12 144
</pre>
=={{header|Jsish}}==
<syntaxhighlight lang="javascript">/* Multiplication tables, is Jsish */
Line 5,148 ⟶ 5,404:
);</syntaxhighlight>
 
Constructing a function to handle cases like this one
[[File:Multiplication table.png|thumb|Formatted output using table_form]]
<syntaxhighlight lang="maxima">
/* Auxiliar function */
aux_table(n,k):=append([k],makelist(0,i,1,k-1),makelist(k*i,i,k,n))$
 
/* Function to construct the formatted table */
table_mult(n):=block(
append([makelist(i,i,0,n)],makelist(aux_table(n,k),k,1,n)),
makelist(at(%%[i],0=""),i,2,length(%%)),
table_form(%%))$
 
/* Test case */
table_mult(12);
</syntaxhighlight>
 
=={{header|МК-61/52}}==
<syntaxhighlight lang="text">П0 КИП0 КИП4 КИП5 ИП4 ИП5 * С/П
ИП5 ИП0 - x=0 03
ИП4 ИП0 - x#0 22 ИП4 П5 БП 02
Line 5,337 ⟶ 5,608:
11 | 121 132
12 | 144</pre>
 
=={{header|N/t/roff}}==
Works with gnu nroff. Please note that the script example contains tab characters which are essential for the correct tabular output.
<syntaxhighlight lang="nroff">
.nf
.ta T 2mR
.nr x 1 1
.nr y 2 1
.nr p 0
.while (\n[x] <= 12) \{\
.if (\n[x]<10) \0\c
\n[x]\c
.if (\n[x]=1) \c
.while (\n[y] <= 12) \{\
.nr p \n[x]*\n[y]
.ie (\n[y]>=\n[x]) \n[p] \c
.el \c
.nr y +1
.\}
.br
.nr x +1
.nr y 1 1
.\}
</syntaxhighlight>
{{out}}
<pre>
1 2 3 4 5 6 7 8 9 10 11 12
2 4 6 8 10 12 14 16 18 20 22 24
3 9 12 15 18 21 24 27 30 33 36
4 16 20 24 28 32 36 40 44 48
5 25 30 35 40 45 50 55 60
6 36 42 48 54 60 66 72
7 49 56 63 70 77 84
8 64 72 80 88 96
9 81 90 99 108
10 100 110 120
11 121 132
12 144
</pre>
 
=={{header|Neko}}==
Line 5,523 ⟶ 5,833:
12| 144
</pre>
 
=={{header|Phixmonti}}==
<syntaxhighlight lang="Phixmonti">/# Rosetta Code problem: https://rosettacode.org/wiki/Multiplication_tables
by Galileo, 11/2022 #/
 
def tab 9 tochar print enddef
 
tab 12 for print tab endfor nl
tab '-' 12 8 * repeat print nl
12 for
dup print tab 8 tochar print "|" print
dup for
over * print tab
endfor
drop nl
endfor</syntaxhighlight>
{{out}}
<pre> 1 2 3 4 5 6 7 8 9 10 11 12
------------------------------------------------------------------------------------------------
1 |1
2 |2 4
3 |3 6 9
4 |4 8 12 16
5 |5 10 15 20 25
6 |6 12 18 24 30 36
7 |7 14 21 28 35 42 49
8 |8 16 24 32 40 48 56 64
9 |9 18 27 36 45 54 63 72 81
10 |10 20 30 40 50 60 70 80 90 100
11 |11 22 33 44 55 66 77 88 99 110 121
12 |12 24 36 48 60 72 84 96 108 120 132 144
 
=== Press any key to exit ===</pre>
 
=={{header|Picat}}==
Line 5,566 ⟶ 5,909:
11 | 121 132
12 | 144</pre>
 
 
=={{header|PicoLisp}}==
Line 5,619 ⟶ 5,961:
Result:
 
<pre>
<syntaxhighlight>
1 2 3 4 5 6 7 8 9 10 11 12
_________________________________________________
Line 5,634 ⟶ 5,976:
11 | 121 132
12 | 144
</pre>
</syntaxhighlight>
 
=={{header|PowerShell}}==
Line 6,725 ⟶ 7,067:
=={{header|Scilab}}==
{{works with|Scilab|5.5.1}}
<syntaxhighlight lang="scilab"> nmax=12, xx=3
s= blanks(xx)+" |"
for j=1:nmax
Line 7,068 ⟶ 7,410:
</pre>
 
=={{header|VBAVBScript}}==
 
<syntaxhighlight lang="vb">
function pad(s,n) if n<0 then pad= right(space(-n) & s ,-n) else pad= left(s& space(n),n) end if
Option Explicit
End Function
 
Sub print(s):
Sub Multiplication_Tables()
On Error Resume Next
Dim strTemp As String, strBuff As String
WScript.stdout.Write (s)
Dim i&, j&, NbDigits As Byte
If err= &h80070006& Then WScript.Echo " Please run this script with CScript": WScript.quit
 
'You can adapt the following const :
Const NB_END As Byte = 12
 
Select Case NB_END
Case Is < 10: NbDigits = 3
Case 10 To 31: NbDigits = 4
Case 31 To 100: NbDigits = 5
Case Else: MsgBox "Number too large": Exit Sub
End Select
strBuff = String(NbDigits, " ")
For i = 1 To NB_END
strTemp = Right(strBuff & i, NbDigits)
For j = 2 To NB_END
If j < i Then
strTemp = strTemp & strBuff
Else
strTemp = strTemp & Right(strBuff & j * i, NbDigits)
End If
Next j
Debug.Print strTemp
Next i
End Sub
For i=1 To 12
print pad(i,-4)
Next
print vbCrLf & String(48,"_")
For i=1 To 12
print vbCrLf
For j=1 To 12
if j<i Then print Space(4) Else print pad(i*j,-4)
Next
print "|"& pad(i,-2)
Next
</syntaxhighlight>
{{out}}
<small>
<pre> 1 2 3 4 5 6 7 8 9 10 11 12
<pre>
2 4 6 8 10 12 14 16 18 20 22 24
31 2 3 9 124 15 5 18 216 24 7 27 308 33 9 36 10 11 12
________________________________________________
4 16 20 24 28 32 36 40 44 48
51 2 3 4 5 6 25 7 30 358 40 9 45 10 50 11 55 12| 601
6 4 6 8 10 12 36 14 42 16 48 18 54 20 60 22 66 24| 722
7 9 12 15 18 21 24 27 4930 5633 6336| 70 77 843
8 16 20 24 28 32 36 40 44 64 48| 72 80 88 964
9 25 30 35 40 45 50 55 60| 81 90 99 1085
10 36 42 48 54 60 66 72| 100 110 1206
11 49 56 63 70 77 84| 121 1327
12 64 72 80 88 96| 144</pre>8
81 90 99 108| 9
 
100 110 120|10
 
121 132|11
144|12
</pre>
</small>
=={{header|Wren}}==
{{libheader|Wren-fmt}}
<syntaxhighlight lang="ecmascriptwren">import "./fmt" for Fmt
 
var nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
Line 7,145 ⟶ 7,479:
12 | 144
</pre>
 
 
=={{header|XPL0}}==
9,476

edits