Multiplication tables: Difference between revisions

Content added Content deleted
(Convert <lang> elements to <syntaxhighlight>)
Line 12: Line 12:
{{trans|C}}
{{trans|C}}


<lang 11l>V n = 12
<syntaxhighlight lang=11l>V n = 12
L(j) 1..n
L(j) 1..n
print(‘#3’.format(j), end' ‘ ’)
print(‘#3’.format(j), end' ‘ ’)
Line 23: Line 23:
L(j) 1..n
L(j) 1..n
print(I j < i {‘ ’} E ‘#3 ’.format(i * j), end' ‘’)
print(I j < i {‘ ’} E ‘#3 ’.format(i * j), end' ‘’)
print(‘│ ’i)</lang>
print(‘│ ’i)</syntaxhighlight>


{{out}}
{{out}}
Line 44: Line 44:


=={{header|360 Assembly}}==
=={{header|360 Assembly}}==
<lang 360asm>* 12*12 multiplication table 14/08/2015
<syntaxhighlight lang=360asm>* 12*12 multiplication table 14/08/2015
MULTTABL CSECT
MULTTABL CSECT
USING MULTTABL,R12
USING MULTTABL,R12
Line 103: Line 103:
PORT DC C'--+-------------------------------------------------'
PORT DC C'--+-------------------------------------------------'
YREGS
YREGS
END MULTTABL</lang>
END MULTTABL</syntaxhighlight>
{{out}}
{{out}}
<pre> | 1 2 3 4 5 6 7 8 9 10 11 12
<pre> | 1 2 3 4 5 6 7 8 9 10 11 12
Line 122: Line 122:
=={{header|8080 Assembly}}==
=={{header|8080 Assembly}}==


<lang 8080asm> org 100h
<syntaxhighlight lang=8080asm> org 100h
lxi h,output
lxi h,output
;;; Make the header
;;; Make the header
Line 218: Line 218:
inx h
inx h
ret
ret
output: equ $</lang>
output: equ $</syntaxhighlight>


{{out}}
{{out}}
Line 240: Line 240:
=={{header|AArch64 Assembly}}==
=={{header|AArch64 Assembly}}==
{{works with|as|Raspberry Pi 3B version Buster 64 bits}}
{{works with|as|Raspberry Pi 3B version Buster 64 bits}}
<lang AArch64 Assembly>
<syntaxhighlight lang=AArch64 Assembly>
/* ARM assembly AARCH64 Raspberry PI 3B */
/* ARM assembly AARCH64 Raspberry PI 3B */
/* program multtable64.s */
/* program multtable64.s */
Line 391: Line 391:
.include "../includeARM64.inc"
.include "../includeARM64.inc"


</syntaxhighlight>
</lang>
{{Output}}
{{Output}}
<pre>
<pre>
Line 410: Line 410:


=={{header|Action!}}==
=={{header|Action!}}==
<lang Action!>PROC PrintRight(BYTE num,size)
<syntaxhighlight lang=Action!>PROC PrintRight(BYTE num,size)
BYTE i
BYTE i


Line 470: Line 470:
OD
OD
OD
OD
RETURN</lang>
RETURN</syntaxhighlight>
{{out}}
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Multiplication_tables.png Screenshot from Atari 8-bit computer]
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Multiplication_tables.png Screenshot from Atari 8-bit computer]
Line 491: Line 491:


=={{header|ActionScript}}==
=={{header|ActionScript}}==
<lang ActionScript>
<syntaxhighlight lang=ActionScript>
package {
package {
Line 571: Line 571:


}
}
</syntaxhighlight>
</lang>


=={{header|Ada}}==
=={{header|Ada}}==
<lang Ada>
<syntaxhighlight lang=Ada>
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
Line 600: Line 600:
end loop;
end loop;
end Multiplication_Table;
end Multiplication_Table;
</syntaxhighlight>
</lang>
<pre>
<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
Line 620: Line 620:
=={{header|Agena}}==
=={{header|Agena}}==
{{Trans|ALGOL_W}}
{{Trans|ALGOL_W}}
<lang agena>scope
<syntaxhighlight lang=agena>scope
# print a school style multiplication table
# print a school style multiplication table
# NB: print outputs a newline at the end, write and printf do not
# NB: print outputs a newline at the end, write and printf do not
Line 633: Line 633:
od;
od;
print()
print()
epocs</lang>
epocs</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 658: Line 658:


<!-- {{does not work with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release 1.8.8d.fc9.i386 - missing printf and FORMAT}} -->
<!-- {{does not work with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release 1.8.8d.fc9.i386 - missing printf and FORMAT}} -->
<lang Algol68>main:(
<syntaxhighlight lang=Algol68>main:(
INT max = 12;
INT max = 12;
INT width = ENTIER(log(max)*2)+1;
INT width = ENTIER(log(max)*2)+1;
Line 676: Line 676:
OD;
OD;
printf(($gl$, hr))
printf(($gl$, hr))
)</lang>
)</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 698: Line 698:


=={{header|ALGOL W}}==
=={{header|ALGOL W}}==
<lang algolw>begin
<syntaxhighlight lang=algolw>begin
% print a school style multiplication table %
% print a school style multiplication table %
i_w := 3; s_w := 0; % set output formating %
i_w := 3; s_w := 0; % set output formating %
Line 711: Line 711:
end;
end;


end.</lang>
end.</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 732: Line 732:
=={{header|APL}}==
=={{header|APL}}==
A simple table is trivial:
A simple table is trivial:
<lang apl>(⍳12)∘.×⍳12</lang>
<syntaxhighlight lang=apl>(⍳12)∘.×⍳12</syntaxhighlight>


But that prints out all the duplicated results across the diagonal:
But that prints out all the duplicated results across the diagonal:
Line 753: Line 753:


{{works with|Dyalog APL}}
{{works with|Dyalog APL}}
<lang apl>⎕←(' ×',2↑' '),4 0⍕⍳12⋄{⎕←((4 0⍕⍵),⊂1(4×(⍵-1))⍴' '),4 0⍕(⍵-1)↓(⍵×⍳12)}¨⍳12</lang>
<syntaxhighlight lang=apl>⎕←(' ×',2↑' '),4 0⍕⍳12⋄{⎕←((4 0⍕⍵),⊂1(4×(⍵-1))⍴' '),4 0⍕(⍵-1)↓(⍵×⍳12)}¨⍳12</syntaxhighlight>


{{works with|GNU APL}}
{{works with|GNU APL}}
After printing the table, GNU APL will will output the value of the expression that produced it, so in addition to adjusting the header spacing this solution uses <tt>⍬⊣</tt> to throw that value away.
After printing the table, GNU APL will will output the value of the expression that produced it, so in addition to adjusting the header spacing this solution uses <tt>⍬⊣</tt> to throw that value away.


<lang apl>⎕←(' ×',4↑' '),4 0⍕⍳12⋄⍬⊣{⎕←((4 0⍕⍵),⊂1(4×(⍵-1))⍴' '),4 0⍕(⍵-1)↓(⍵×⍳12)}¨⍳12</lang>
<syntaxhighlight lang=apl>⎕←(' ×',4↑' '),4 0⍕⍳12⋄⍬⊣{⎕←((4 0⍕⍵),⊂1(4×(⍵-1))⍴' '),4 0⍕(⍵-1)↓(⍵×⍳12)}¨⍳12</syntaxhighlight>


{{Out}}
{{Out}}
Line 777: Line 777:
=={{header|AppleScript}}==
=={{header|AppleScript}}==
===Iteration===
===Iteration===
<lang AppleScript >set n to 12 -- Size of table.
<syntaxhighlight lang=AppleScript >set n to 12 -- Size of table.
repeat with x from 0 to n
repeat with x from 0 to n
if x = 0 then set {table, x} to {{return}, -1}
if x = 0 then set {table, x} to {{return}, -1}
Line 797: Line 797:
set text item delimiters to ""
set text item delimiters to ""
return (characters -4 thru -1 of (" " & x)) as string
return (characters -4 thru -1 of (" " & x)) as string
end f</lang>
end f</syntaxhighlight>
{{out}}
{{out}}
<pre>"
<pre>"
Line 819: Line 819:


{{trans|JavaScript}} (ES5 functional version)
{{trans|JavaScript}} (ES5 functional version)
<lang AppleScript>------------------- MULTIPLICATION TABLE -----------------
<syntaxhighlight lang=AppleScript>------------------- MULTIPLICATION TABLE -----------------


-- multiplicationTable :: Int -> Int -> String
-- multiplicationTable :: Int -> Int -> String
Line 1,001: Line 1,001:
end repeat
end repeat
return out & dbl
return out & dbl
end replicate</lang>
end replicate</syntaxhighlight>
{{Out}}
{{Out}}
<pre> x 1 2 3 4 5 6 7 8 9 10 11 12
<pre> x 1 2 3 4 5 6 7 8 9 10 11 12
Line 1,034: Line 1,034:
=={{header|ARM Assembly}}==
=={{header|ARM Assembly}}==
{{works with|as|Raspberry Pi}}
{{works with|as|Raspberry Pi}}
<lang ARM Assembly>
<syntaxhighlight lang=ARM Assembly>


/* ARM assembly Raspberry PI */
/* ARM assembly Raspberry PI */
Line 1,217: Line 1,217:




</syntaxhighlight>
</lang>


=={{header|Arturo}}==
=={{header|Arturo}}==
<lang rebol>mulTable: function [n][
<syntaxhighlight lang=rebol>mulTable: function [n][
print [" |"] ++ map 1..n => [pad to :string & 3]
print [" |"] ++ map 1..n => [pad to :string & 3]
print "----+" ++ join map 1..n => "----"
print "----+" ++ join map 1..n => "----"
Line 1,231: Line 1,231:
]
]


mulTable 12</lang>
mulTable 12</syntaxhighlight>


{{out}}
{{out}}
Line 1,252: Line 1,252:
=={{header|ASIC}}==
=={{header|ASIC}}==
{{trans|Modula-2}}
{{trans|Modula-2}}
<lang basic>
<syntaxhighlight lang=basic>
REM Multiplication tables
REM Multiplication tables
N = 12
N = 12
Line 1,299: Line 1,299:
PRINT S2$;
PRINT S2$;
RETURN
RETURN
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>
<pre>
Line 1,319: Line 1,319:


=={{header|AutoHotkey}}==
=={{header|AutoHotkey}}==
<lang autohotkey>Gui, -MinimizeBox
<syntaxhighlight lang=autohotkey>Gui, -MinimizeBox
Gui, Margin, 0, 0
Gui, Margin, 0, 0
Gui, Font, s9, Fixedsys
Gui, Font, s9, Fixedsys
Line 1,354: Line 1,354:
}
}
GuiControl,, Edit2, %Table%
GuiControl,, Edit2, %Table%
Return</lang>
Return</syntaxhighlight>
Message box shows:
Message box shows:
<pre> x | 1 2 3 4 5 6 7 8 9 10 11 12
<pre> x | 1 2 3 4 5 6 7 8 9 10 11 12
Line 1,373: Line 1,373:


=={{header|AutoIt}}==
=={{header|AutoIt}}==
<lang AutoIt>#AutoIt Version: 3.2.10.0
<syntaxhighlight lang=AutoIt>#AutoIt Version: 3.2.10.0
$tableupto=12
$tableupto=12
$table=""
$table=""
Line 1,392: Line 1,392:
Next
Next
Next
Next
msgbox(0,"Multiplication Tables",$table)</lang>
msgbox(0,"Multiplication Tables",$table)</syntaxhighlight>


=={{header|AWK}}==
=={{header|AWK}}==
<lang AWK>
<syntaxhighlight lang=AWK>
BEGIN {
BEGIN {
for(i=1;i<=12;i++){
for(i=1;i<=12;i++){
Line 1,404: Line 1,404:
print
print
}
}
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 1,423: Line 1,423:
=={{header|Axe}}==
=={{header|Axe}}==
Since the standard text output is poorly suited to this kind of formatted data, this example is implemented by writing to the screen buffer using the small font. Also, the limits were adjusted to 10x8 to make the table fit the screen.
Since the standard text output is poorly suited to this kind of formatted data, this example is implemented by writing to the screen buffer using the small font. Also, the limits were adjusted to 10x8 to make the table fit the screen.
<lang axe>Fix 5
<syntaxhighlight lang=axe>Fix 5
ClrDraw
ClrDraw
For(I,1,10)
For(I,1,10)
Line 1,440: Line 1,440:
DispGraph
DispGraph
getKeyʳ
getKeyʳ
Fix 4</lang>
Fix 4</syntaxhighlight>


Approximate output:
Approximate output:
Line 1,460: Line 1,460:


==={{header|Applesoft BASIC}}===
==={{header|Applesoft BASIC}}===
<lang ApplesoftBasic>100 M = 12
<syntaxhighlight lang=ApplesoftBasic>100 M = 12
110 DEF FN T(X) = X * 3 + (X < 4) * (4 - X) + (X > 10) * (X - 10) - 1
110 DEF FN T(X) = X * 3 + (X < 4) * (4 - X) + (X > 10) * (X - 10) - 1
120 FOR N = -1 TO M
120 FOR N = -1 TO M
Line 1,469: Line 1,469:
170 V$ = STR$(I * J)
170 V$ = STR$(I * J)
180 PRINT TAB(FN T(J)) MID$(" ", 1, 3 - LEN(V$) - (J < 4)) V$;
180 PRINT TAB(FN T(J)) MID$(" ", 1, 3 - LEN(V$) - (J < 4)) V$;
190 NEXT J, N</lang>
190 NEXT J, N</syntaxhighlight>


==={{header|BASIC256}}===
==={{header|BASIC256}}===
<lang freebasic>print " X| 1 2 3 4 5 6 7 8 9 10 11 12"
<syntaxhighlight lang=freebasic>print " X| 1 2 3 4 5 6 7 8 9 10 11 12"
print "---+------------------------------------------------"
print "---+------------------------------------------------"


Line 1,488: Line 1,488:
next j
next j
print nums$
print nums$
next i</lang>
next i</syntaxhighlight>


==={{header|BBC BASIC}}===
==={{header|BBC BASIC}}===
BBC BASIC automatically right-justifies numeric output.
BBC BASIC automatically right-justifies numeric output.
<lang bbcbasic> @% = 5 : REM Set column width
<syntaxhighlight lang=bbcbasic> @% = 5 : REM Set column width
FOR row% = 1 TO 12
FOR row% = 1 TO 12
PRINT row% TAB(row% * @%) ;
PRINT row% TAB(row% * @%) ;
Line 1,499: Line 1,499:
NEXT col%
NEXT col%
PRINT
PRINT
NEXT row%</lang>
NEXT row%</syntaxhighlight>
{{out}}
{{out}}
<pre> 1 1 2 3 4 5 6 7 8 9 10 11 12
<pre> 1 1 2 3 4 5 6 7 8 9 10 11 12
Line 1,516: Line 1,516:
==={{header|Commodore BASIC}}===
==={{header|Commodore BASIC}}===
The table consumes every one of the 1000 cells in a 40-column display, and even so has to cheat a little to fit 10x10=100 into the table. It uses the INSERT character (<tt>CHR$(148)</tt>) to push characters over to the right after printing them without triggering a scroll that would push the top line off the screen.
The table consumes every one of the 1000 cells in a 40-column display, and even so has to cheat a little to fit 10x10=100 into the table. It uses the INSERT character (<tt>CHR$(148)</tt>) to push characters over to the right after printing them without triggering a scroll that would push the top line off the screen.
<lang gwbasic>100 PRINT CHR$(14);CHR$(147);
<syntaxhighlight lang=gwbasic>100 PRINT CHR$(14);CHR$(147);
110 PRINT " X";
110 PRINT " X";
120 W=2
120 W=2
Line 1,560: Line 1,560:
520 N$=MID$(STR$(N),2)
520 N$=MID$(STR$(N),2)
530 IF LEN(N$)<W THEN N$=" "+N$:GOTO 530
530 IF LEN(N$)<W THEN N$=" "+N$:GOTO 530
540 RETURN</lang>
540 RETURN</syntaxhighlight>


{{Out}}
{{Out}}
Line 1,589: Line 1,589:
12: : : : : : : : : : : :144</pre>
12: : : : : : : : : : : :144</pre>
==={{header|FreeBASIC}}===
==={{header|FreeBASIC}}===
<lang freebasic>
<syntaxhighlight lang=freebasic>
' FB 1.05.0 Win64
' FB 1.05.0 Win64


Line 1,611: Line 1,611:
Print
Print
Print "Press any key to quit"
Print "Press any key to quit"
Sleep</lang>
Sleep</syntaxhighlight>


{{out}}
{{out}}
Line 1,632: Line 1,632:


==={{header|FutureBasic}}===
==={{header|FutureBasic}}===
<syntaxhighlight>
<lang>
long i, j
long i, j


Line 1,652: Line 1,652:


HandleEvents
HandleEvents
</syntaxhighlight>
</lang>
{{output}}
{{output}}
<pre>
<pre>
Line 1,674: Line 1,674:
{{trans|Modula-2}}
{{trans|Modula-2}}
{{works with|PC-BASIC|any}}
{{works with|PC-BASIC|any}}
<lang qbasic>
<syntaxhighlight lang=qbasic>
10 ' Multiplication Tables
10 ' Multiplication Tables
20 LET N% = 12
20 LET N% = 12
Line 1,692: Line 1,692:
160 PRINT "| "; USING "##"; I%
160 PRINT "| "; USING "##"; I%
170 NEXT I%
170 NEXT I%
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>
<pre>
Line 1,712: Line 1,712:


==={{header|IS-BASIC}}===
==={{header|IS-BASIC}}===
<lang IS-BASIC>100 PROGRAM "Multipli.bas"
<syntaxhighlight lang=IS-BASIC>100 PROGRAM "Multipli.bas"
110 TEXT 80
110 TEXT 80
120 PRINT TAB(7);
120 PRINT TAB(7);
Line 1,725: Line 1,725:
210 NEXT
210 NEXT
220 PRINT
220 PRINT
230 NEXT</lang>
230 NEXT</syntaxhighlight>


==={{header|Liberty BASIC}}===
==={{header|Liberty BASIC}}===
<lang lb>Print " | 1 2 3 4 5 6 7 8 9 10 11 12"
<syntaxhighlight lang=lb>Print " | 1 2 3 4 5 6 7 8 9 10 11 12"
Print "--+------------------------------------------------------------"
Print "--+------------------------------------------------------------"


Line 1,744: Line 1,744:
Next ii
Next ii
Print nums$
Print nums$
Next i</lang>
Next i</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 1,765: Line 1,765:
==={{header|Microsoft Small Basic}}===
==={{header|Microsoft Small Basic}}===
{{trans|Modula-2}}
{{trans|Modula-2}}
<lang microsoftsmallbasic>
<syntaxhighlight lang=microsoftsmallbasic>
n = 12
n = 12
For j = 1 To n - 1
For j = 1 To n - 1
Line 1,794: Line 1,794:
TextWindow.WriteLine("")
TextWindow.WriteLine("")
EndFor
EndFor
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>
<pre>
Line 1,814: Line 1,814:


==={{header|PureBasic}}===
==={{header|PureBasic}}===
<lang PureBasic>Procedure PrintMultiplicationTable(maxx, maxy)
<syntaxhighlight lang=PureBasic>Procedure PrintMultiplicationTable(maxx, maxy)
sp = Len(Str(maxx*maxy)) + 1
sp = Len(Str(maxx*maxy)) + 1
trenner$ = "+"
trenner$ = "+"
Line 1,848: Line 1,848:
OpenConsole()
OpenConsole()
PrintMultiplicationTable(12, 12)
PrintMultiplicationTable(12, 12)
Input()</lang>
Input()</syntaxhighlight>


Ouput similar to ALGOL 68
Ouput similar to ALGOL 68


==={{header|QBasic}}===
==={{header|QBasic}}===
<lang qbasic>CLS
<syntaxhighlight lang=qbasic>CLS


'header row
'header row
Line 1,878: Line 1,878:
PRINT o$;
PRINT o$;
NEXT
NEXT
NEXT</lang>
NEXT</syntaxhighlight>


{{out}}
{{out}}
Line 1,899: Line 1,899:


==={{header|Run BASIC}}===
==={{header|Run BASIC}}===
<lang Runbasic>html "<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>"
<syntaxhighlight lang=Runbasic>html "<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>"
For i = 1 To 12
For i = 1 To 12
html "<TR align=right><TD>";i;"</td>"
html "<TR align=right><TD>";i;"</td>"
Line 1,909: Line 1,909:
next i
next i
html "</table>"
html "</table>"
</lang>Output:
</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>
<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|True BASIC}}===
==={{header|True BASIC}}===
<lang qbasic>PRINT " X| 1 2 3 4 5 6 7 8 9 10 11 12"
<syntaxhighlight lang=qbasic>PRINT " X| 1 2 3 4 5 6 7 8 9 10 11 12"
PRINT "---+------------------------------------------------"
PRINT "---+------------------------------------------------"


Line 1,929: Line 1,929:
NEXT i
NEXT i
PRINT
PRINT
END</lang>
END</syntaxhighlight>


==={{header|uBasic/4tH}}===
==={{header|uBasic/4tH}}===
{{trans|BBC BASIC}}
{{trans|BBC BASIC}}
<lang>For R = 1 To 12
<syntaxhighlight>For R = 1 To 12
Print R;Tab(R * 5);
Print R;Tab(R * 5);
For C = R To 12
For C = R To 12
Line 1,939: Line 1,939:
Next
Next
Print
Print
Next</lang>
Next</syntaxhighlight>
{{out}}
{{out}}
<pre>1 1 2 3 4 5 6 7 8 9 10 11 12
<pre>1 1 2 3 4 5 6 7 8 9 10 11 12
Line 1,958: Line 1,958:
==={{header|Visual Basic}}===
==={{header|Visual Basic}}===
{{works with|Visual Basic|VB6 Standard}}
{{works with|Visual Basic|VB6 Standard}}
<lang vb>Sub Main()
<syntaxhighlight lang=vb>Sub Main()
Const nmax = 12, xx = 3
Const nmax = 12, xx = 3
Const x = xx + 1
Const x = xx + 1
Line 1,981: Line 1,981:
Debug.Print s
Debug.Print s
Next i
Next i
End Sub 'Main</lang>
End Sub 'Main</syntaxhighlight>
{{Out}}
{{Out}}
<pre>
<pre>
Line 2,003: Line 2,003:
{{trans|Modula-2}}
{{trans|Modula-2}}
{{works with|Windows XBasic}}
{{works with|Windows XBasic}}
<lang xbasic>
<syntaxhighlight lang=xbasic>
PROGRAM "multiplicationtables"
PROGRAM "multiplicationtables"
VERSION "0.0001"
VERSION "0.0001"
Line 2,031: Line 2,031:
END FUNCTION
END FUNCTION
END PROGRAM
END PROGRAM
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>
<pre>
Line 2,051: Line 2,051:


==={{header|Yabasic}}===
==={{header|Yabasic}}===
<lang freebasic>print " X| 1 2 3 4 5 6 7 8 9 10 11 12"
<syntaxhighlight lang=freebasic>print " X| 1 2 3 4 5 6 7 8 9 10 11 12"
print "---+------------------------------------------------"
print "---+------------------------------------------------"


Line 2,067: Line 2,067:
next j
next j
print nums$
print nums$
next i</lang>
next i</syntaxhighlight>


=={{header|Batch File}}==
=={{header|Batch File}}==
<lang dos>@echo off
<syntaxhighlight lang=dos>@echo off
setlocal enabledelayedexpansion
setlocal enabledelayedexpansion


Line 2,116: Line 2,116:
for /l %%A in (1,1,%numspaces%) do set "space=!space! "
for /l %%A in (1,1,%numspaces%) do set "space=!space! "
goto :EOF
goto :EOF
::/The Functions.</lang>
::/The Functions.</syntaxhighlight>
{{Out}}
{{Out}}
<pre>
<pre>
Line 2,137: Line 2,137:


=={{header|Befunge}}==
=={{header|Befunge}}==
<lang befunge>0>51p0>52p51g52g*:51g52g`!*\!51g52g+*+0\3>01p::55+%68*+\!28v
<syntaxhighlight lang=befunge>0>51p0>52p51g52g*:51g52g`!*\!51g52g+*+0\3>01p::55+%68*+\!28v
w^p2<y|!`+66:+1,+*84*"\"!:g25$_,#!>#:<$$_^#!:-1g10/+55\-**<<
w^p2<y|!`+66:+1,+*84*"\"!:g25$_,#!>#:<$$_^#!:-1g10/+55\-**<<
"$9"^x>$55+,51g1+:66+`#@_055+68*\>\#<1#*-#9:#5_$"+---">:#,_$</lang>
"$9"^x>$55+,51g1+:66+`#@_055+68*\>\#<1#*-#9:#5_$"+---">:#,_$</syntaxhighlight>


{{out}}
{{out}}
Line 2,161: Line 2,161:
<code>Table</code> formats a multiplication table for any given n. The result is a character array and can be printed with <code>•Out˘</code>. The overall structure is to build a 3-by-3 array of parts, then put them together with a two-dimensional join (<code>∾</code>).
<code>Table</code> formats a multiplication table for any given n. The result is a character array and can be printed with <code>•Out˘</code>. The overall structure is to build a 3-by-3 array of parts, then put them together with a two-dimensional join (<code>∾</code>).


<lang bqn>Table ← {
<syntaxhighlight lang=bqn>Table ← {
m ← •Repr¨ ×⌜˜1+↕𝕩 # The numbers, formatted individually
m ← •Repr¨ ×⌜˜1+↕𝕩 # The numbers, formatted individually
main ← ⟨ # Bottom part: three sections
main ← ⟨ # Bottom part: three sections
Line 2,172: Line 2,172:
}
}
•Out˘ Table 12</lang>
•Out˘ Table 12</syntaxhighlight>
{{Out}}
{{Out}}
<lang> | 1 2 3 4 5 6 7 8 9 10 11 12
<syntaxhighlight> | 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
1| 1 2 3 4 5 6 7 8 9 10 11 12
Line 2,187: Line 2,187:
10| 100 110 120
10| 100 110 120
11| 121 132
11| 121 132
12| 144</lang>
12| 144</syntaxhighlight>


=={{header|Bracmat}}==
=={{header|Bracmat}}==
<lang Bracmat> ( multiplicationTable
<syntaxhighlight lang=Bracmat> ( multiplicationTable
= high i j row row2 matrix padFnc tmp
= high i j row row2 matrix padFnc tmp
, celPad leftCelPad padFnc celDashes leftDashes
, celPad leftCelPad padFnc celDashes leftDashes
Line 2,245: Line 2,245:
)
)
& out$(multiplicationTable$12)
& out$(multiplicationTable$12)
& done;</lang>
& done;</syntaxhighlight>
{{out}}
{{out}}
<pre> X| 1 2 3 4 5 6 7 8 9 10 11 12
<pre> X| 1 2 3 4 5 6 7 8 9 10 11 12
Line 2,263: Line 2,263:


=={{header|C}}==
=={{header|C}}==
<lang c>#include <stdio.h>
<syntaxhighlight lang=c>#include <stdio.h>


int main(void)
int main(void)
Line 2,279: Line 2,279:
return 0;
return 0;
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre> 1 2 3 4 5 6 7 8 9 10 11 12
<pre> 1 2 3 4 5 6 7 8 9 10 11 12
Line 2,297: Line 2,297:


=={{header|C sharp}}==
=={{header|C sharp}}==
<lang csharp>using System;
<syntaxhighlight lang=csharp>using System;


namespace multtbl
namespace multtbl
Line 2,335: Line 2,335:
}
}
}
}
</syntaxhighlight>
</lang>


{{out}}
{{out}}
Line 2,359: Line 2,359:
and formats the table columns.
and formats the table columns.


<lang cpp>#include <iostream>
<syntaxhighlight lang=cpp>#include <iostream>
#include <iomanip>
#include <iomanip>
#include <cmath> // for log10()
#include <cmath> // for log10()
Line 2,436: Line 2,436:
return 0;
return 0;
}
}
</syntaxhighlight>
</lang>


{{out}}
{{out}}
Line 2,470: Line 2,470:
=={{header|Chef}}==
=={{header|Chef}}==


<lang chef>Multigrain Bread.
<syntaxhighlight lang=chef>Multigrain Bread.


Prints out a multiplication table.
Prints out a multiplication table.
Line 2,534: Line 2,534:
Pour contents of the 2nd mixing bowl into the 2nd baking dish.
Pour contents of the 2nd mixing bowl into the 2nd baking dish.


Serves 2.</lang>
Serves 2.</syntaxhighlight>


{{out}}
{{out}}
Line 2,555: Line 2,555:
This is more generalized.
This is more generalized.
Any size can be used and the table will be formatted appropriately.
Any size can be used and the table will be formatted appropriately.
<lang lisp>(let [size 12
<syntaxhighlight lang=lisp>(let [size 12
trange (range 1 (inc size))
trange (range 1 (inc size))
fmt-width (+ (.length (str (* size size))) 1)
fmt-width (+ (.length (str (* size size))) 1)
Line 2,568: Line 2,568:
(for [j trange] j))))))]
(for [j trange] j))))))]
(println s)))
(println s)))
</syntaxhighlight>
</lang>


{{out}}
{{out}}
Line 2,587: Line 2,587:


=={{header|COBOL}}==
=={{header|COBOL}}==
<lang COBOL> identification division.
<syntaxhighlight lang=COBOL> identification division.
program-id. multiplication-table.
program-id. multiplication-table.


Line 2,633: Line 2,633:
goback.
goback.
end program multiplication-table.
end program multiplication-table.
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>prompt$ cobc -xj multiplication-table.cob
<pre>prompt$ cobc -xj multiplication-table.cob
Line 2,651: Line 2,651:


=={{header|CoffeeScript}}==
=={{header|CoffeeScript}}==
<lang coffeescript>
<syntaxhighlight lang=coffeescript>
print_multiplication_tables = (n) ->
print_multiplication_tables = (n) ->
width = 4
width = 4
Line 2,683: Line 2,683:
print_multiplication_tables 12
print_multiplication_tables 12
</syntaxhighlight>
</lang>


{{out}}
{{out}}
Line 2,705: Line 2,705:


=={{header|Common Lisp}}==
=={{header|Common Lisp}}==
<lang lisp>
<syntaxhighlight lang=lisp>
(do ((m 0 (if (= 12 m) 0 (1+ m)))
(do ((m 0 (if (= 12 m) 0 (1+ m)))
(n 0 (if (= 12 m) (1+ n) n)))
(n 0 (if (= 12 m) (1+ n) n)))
Line 2,722: Line 2,722:
(format t "~4,D" (* m n))
(format t "~4,D" (* m n))
(format t " "))))))
(format t " "))))))
</syntaxhighlight>
</lang>
Output:
Output:
<pre>
<pre>
Line 2,744: Line 2,744:
=={{header|D}}==
=={{header|D}}==
{{trans|PicoLisp}}
{{trans|PicoLisp}}
<lang d>void main() {
<syntaxhighlight lang=d>void main() {
import std.stdio, std.array, std.range, std.algorithm;
import std.stdio, std.array, std.range, std.algorithm;


Line 2,752: Line 2,752:
writefln("%4d" ~ " ".replicate(4 * (y - 1)) ~ "%(%4d%)", y,
writefln("%4d" ~ " ".replicate(4 * (y - 1)) ~ "%(%4d%)", y,
iota(y, n + 1).map!(x => x * y));
iota(y, n + 1).map!(x => x * y));
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre> 1 2 3 4 5 6 7 8 9 10 11 12
<pre> 1 2 3 4 5 6 7 8 9 10 11 12
Line 2,770: Line 2,770:


=={{header|DCL}}==
=={{header|DCL}}==
<lang DCL>$ max = 12
<syntaxhighlight lang=DCL>$ max = 12
$ h = f$fao( "!4* " )
$ h = f$fao( "!4* " )
$ r = 0
$ r = 0
Line 2,795: Line 2,795:
$ write sys$output f$fao( "!4SL", r ) + o
$ write sys$output f$fao( "!4SL", r ) + o
$ r = r + 1
$ r = r + 1
$ if r .le. max then $ goto loop1</lang>
$ if r .le. max then $ goto loop1</syntaxhighlight>
{{out}}
{{out}}
<pre>$ @multiplication_tables
<pre>$ @multiplication_tables
Line 2,817: Line 2,817:
=={{header|Delphi}}==
=={{header|Delphi}}==
{{trans|DWScript}}
{{trans|DWScript}}
<lang delphi>program MultiplicationTables;
<syntaxhighlight lang=delphi>program MultiplicationTables;


{$APPTYPE CONSOLE}
{$APPTYPE CONSOLE}
Line 2,846: Line 2,846:
Writeln;
Writeln;
end;
end;
end.</lang>
end.</syntaxhighlight>


=={{header|Draco}}==
=={{header|Draco}}==
<lang draco>/* Print N-by-N multiplication table */
<syntaxhighlight lang=draco>/* Print N-by-N multiplication table */
proc nonrec multab(byte n) void:
proc nonrec multab(byte n) void:
byte i,j;
byte i,j;
Line 2,874: Line 2,874:


/* Print 12-by-12 multiplication table */
/* Print 12-by-12 multiplication table */
proc nonrec main() void: multab(12) corp</lang>
proc nonrec main() void: multab(12) corp</syntaxhighlight>
{{out}}
{{out}}
<pre> | 1 2 3 4 5 6 7 8 9 10 11 12
<pre> | 1 2 3 4 5 6 7 8 9 10 11 12
Line 2,893: Line 2,893:
=={{header|DWScript}}==
=={{header|DWScript}}==


<lang delphi>const size = 12;
<syntaxhighlight lang=delphi>const size = 12;
var row, col : Integer;
var row, col : Integer;


Line 2,911: Line 2,911:
PrintLn('');
PrintLn('');
end;
end;
</syntaxhighlight>
</lang>


=={{header|E}}==
=={{header|E}}==


<lang e> def size := 12
<syntaxhighlight lang=e> def size := 12
println(`{|style="border-collapse: collapse; text-align: right;"`)
println(`{|style="border-collapse: collapse; text-align: right;"`)
println(`|`)
println(`|`)
Line 2,928: Line 2,928:
}
}
}
}
println("|}")</lang>
println("|}")</syntaxhighlight>


Targets MediaWiki markup.
Targets MediaWiki markup.
Line 3,120: Line 3,120:
=={{header|EasyLang}}==
=={{header|EasyLang}}==


<lang>n = 12
<syntaxhighlight>n = 12
func out h . .
func out h . .
if h < 10
if h < 10
Line 3,151: Line 3,151:
.
.
print ""
print ""
.</lang>
.</syntaxhighlight>


=={{header|EchoLisp}}==
=={{header|EchoLisp}}==
<lang scheme>
<syntaxhighlight lang=scheme>
(lib 'matrix)
(lib 'matrix)


Line 3,167: Line 3,167:
(array-print (build-array 13 13 mtable))
(array-print (build-array 13 13 mtable))


</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>
<pre>
Line 3,186: Line 3,186:


=={{header|Elixir}}==
=={{header|Elixir}}==
<lang elixir>defmodule RC do
<syntaxhighlight lang=elixir>defmodule RC do
def multiplication_tables(n) do
def multiplication_tables(n) do
IO.write " X |"
IO.write " X |"
Line 3,201: Line 3,201:
end
end


RC.multiplication_tables(12)</lang>
RC.multiplication_tables(12)</syntaxhighlight>


{{out}}
{{out}}
Line 3,222: Line 3,222:


=={{header|Erlang}}==
=={{header|Erlang}}==
<lang Erlang>
<syntaxhighlight lang=Erlang>
-module( multiplication_tables ).
-module( multiplication_tables ).


Line 3,247: Line 3,247:
[io:fwrite("~5B", [Sum]) || {_Y, Sum} <- Uptos],
[io:fwrite("~5B", [Sum]) || {_Y, Sum} <- Uptos],
io:nl().
io:nl().
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>
<pre>
Line 3,268: Line 3,268:


=={{header|Euphoria}}==
=={{header|Euphoria}}==
<lang Euphoria>puts(1," x")
<syntaxhighlight lang=Euphoria>puts(1," x")
for i = 1 to 12 do
for i = 1 to 12 do
printf(1," %3d",i)
printf(1," %3d",i)
Line 3,285: Line 3,285:
end for
end for
puts(1,'\n')
puts(1,'\n')
end for</lang>
end for</syntaxhighlight>


{{out}}
{{out}}
Line 3,312: Line 3,312:


{{Works with|Office 365 betas 2021}}
{{Works with|Office 365 betas 2021}}
<lang lisp>FNOVERHALFCARTESIANPRODUCT
<syntaxhighlight lang=lisp>FNOVERHALFCARTESIANPRODUCT
=LAMBDA(f,
=LAMBDA(f,
LAMBDA(n,
LAMBDA(n,
Line 3,328: Line 3,328:
)
)
)
)
)</lang>
)</syntaxhighlight>


and also assuming the following generic bindings in the Name Manager for the WorkBook:
and also assuming the following generic bindings in the Name Manager for the WorkBook:


<lang lisp>MUL
<syntaxhighlight lang=lisp>MUL
=LAMBDA(a, LAMBDA(b, a * b))
=LAMBDA(a, LAMBDA(b, a * b))


Line 3,341: Line 3,341:
POWER(n, e)
POWER(n, e)
)
)
)</lang>
)</syntaxhighlight>


(The single formula in cell '''B2''' below populates the whole 12*12 grid)
(The single formula in cell '''B2''' below populates the whole 12*12 grid)
Line 3,758: Line 3,758:
=={{header|F Sharp|F#}}==
=={{header|F Sharp|F#}}==
Translation of C#
Translation of C#
<lang FSharp>
<syntaxhighlight lang=FSharp>
open System
open System


Line 3,778: Line 3,778:


multTable ()
multTable ()
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>
<pre>
Line 3,798: Line 3,798:


=={{header|Factor}}==
=={{header|Factor}}==
<lang factor>USING: io kernel math math.parser math.ranges sequences ;
<syntaxhighlight lang=factor>USING: io kernel math math.parser math.ranges sequences ;
IN: multiplication-table
IN: multiplication-table


Line 3,814: Line 3,814:
" +" write
" +" write
12 [ "----" write ] times nl
12 [ "----" write ] times nl
1 12 [a,b] [ print-row ] each ;</lang>
1 12 [a,b] [ print-row ] each ;</syntaxhighlight>


<pre>
<pre>
Line 3,834: Line 3,834:


=={{header|FALSE}}==
=={{header|FALSE}}==
<lang false>[$100\>[" "]?$10\>[" "]?." "]p:
<syntaxhighlight lang=false>[$100\>[" "]?$10\>[" "]?." "]p:
[$p;! m: 2[$m;\>][" "1+]# [$13\>][$m;*p;!1+]#%"
[$p;! m: 2[$m;\>][" "1+]# [$13\>][$m;*p;!1+]#%"
"]l:
"]l:
1[$13\>][$l;!1+]#%</lang>
1[$13\>][$l;!1+]#%</syntaxhighlight>


=={{header|Fantom}}==
=={{header|Fantom}}==


<lang fantom>
<syntaxhighlight lang=fantom>
class Main
class Main
{
{
Line 3,863: Line 3,863:
}
}
}
}
</syntaxhighlight>
</lang>


=={{header|Forth}}==
=={{header|Forth}}==
<lang forth>
<syntaxhighlight lang=forth>
: multiplication-table
: multiplication-table
cr 2 spaces 13 2 do i 4 u.r loop
cr 2 spaces 13 2 do i 4 u.r loop
Line 3,876: Line 3,876:
loop
loop
loop ;
loop ;
</syntaxhighlight>
</lang>


=={{header|Fortran}}==
=={{header|Fortran}}==
{{works with|Fortran|90 and later}}
{{works with|Fortran|90 and later}}
<lang fortran>program multtable
<syntaxhighlight lang=fortran>program multtable
implicit none
implicit none


Line 3,898: Line 3,898:
end do
end do


end program multtable</lang>
end program multtable</syntaxhighlight>


===Traditional approach===
===Traditional approach===
Line 3,904: Line 3,904:


So instead, write the table by first writing a line to a CHARACTER variable then blanking out the unwanted part.
So instead, write the table by first writing a line to a CHARACTER variable then blanking out the unwanted part.
<lang Fortran>
<syntaxhighlight lang=Fortran>
Cast forth a twelve times table, suitable for chanting at school.
Cast forth a twelve times table, suitable for chanting at school.
INTEGER I,J !Steppers.
INTEGER I,J !Steppers.
Line 3,916: Line 3,916:
3 WRITE (6,"(A)") ALINE !Print the text.
3 WRITE (6,"(A)") ALINE !Print the text.
END !"One one is one! One two is two! One three is three!...
END !"One one is one! One two is two! One three is three!...
</syntaxhighlight>
</lang>
Output in the same style as above, with underlining unavailable: those who have used a lineprinter's overprint facility to properly underline find the flabby modern requirement of a second line vexing, but, few output devices support underlining in so easy a way.
Output in the same style as above, with underlining unavailable: those who have used a lineprinter's overprint facility to properly underline find the flabby modern requirement of a second line vexing, but, few output devices support underlining in so easy a way.
×| 1 2 3 4 5 6 7 8 9 10 11 12
×| 1 2 3 4 5 6 7 8 9 10 11 12
Line 3,933: Line 3,933:
12| 144
12| 144
Going to the trouble of preparing results, and then blanking some might seem a little too crude. An alternative would be to use a different FORMAT statement for each line of output. But, a collection of a dozen output statements hardly represents a programming solution. Instead, create and then use the text of FORMAT statements, as follows. Notice that there are ''no reserved words'' in Fortran.
Going to the trouble of preparing results, and then blanking some might seem a little too crude. An alternative would be to use a different FORMAT statement for each line of output. But, a collection of a dozen output statements hardly represents a programming solution. Instead, create and then use the text of FORMAT statements, as follows. Notice that there are ''no reserved words'' in Fortran.
<lang Fortran>
<syntaxhighlight lang=Fortran>
Cast forth a twelve times table, suitable for chanting at school.
Cast forth a twelve times table, suitable for chanting at school.
INTEGER I,J !Steppers.
INTEGER I,J !Steppers.
Line 3,944: Line 3,944:
3 WRITE (6,FORMAT) I,(I*J, J = I,12) !Use it.
3 WRITE (6,FORMAT) I,(I*J, J = I,12) !Use it.
END !"One one is one! One two is two! One three is three!...
END !"One one is one! One two is two! One three is three!...
</syntaxhighlight>
</lang>
The output is the same, so instead, here are the generated FORMAT texts:
The output is the same, so instead, here are the generated FORMAT texts:
(I3,'|',0X,12I4)
(I3,'|',0X,12I4)
Line 3,965: Line 3,965:


===VAX FORTRAN===
===VAX FORTRAN===
<lang Fortran>
<syntaxhighlight lang=Fortran>
PROGRAM TABLES
PROGRAM TABLES
IMPLICIT NONE
IMPLICIT NONE
Line 3,990: Line 3,990:
C
C
END
END
</lang>Based on the above code but with a slight modification as VAX FORTRAN doesn't allow zero width fields in a format statement. The number of rows and columns can also be altered by modifying the value of K which must be in the range 1 - 25.
</syntaxhighlight>Based on the above code but with a slight modification as VAX FORTRAN doesn't allow zero width fields in a format statement. The number of rows and columns can also be altered by modifying the value of K which must be in the range 1 - 25.
===FORTRAN-IV===
===FORTRAN-IV===
<lang Fortran> PROGRAM TABLES
<syntaxhighlight lang=Fortran> PROGRAM TABLES
C
C
C Produce a formatted multiplication table of the kind memorised by rote
C Produce a formatted multiplication table of the kind memorised by rote
Line 4,026: Line 4,026:
3 CONTINUE
3 CONTINUE
C
C
END</lang>Rather more changes are needed to produce the same result, in particular we cannot modify the format specifier directly and have to rely on overlaying it with an integer array and calculating the ASCII values needed for each byte we need to modify. Nested implicit DO loops are allowed, but not used as it isn't possible to compute K on the fly so we have to calculate (and store) the results for each row before printing it. Note also that the unit numbers for the output devices are different and when using Hollerith strings to define values in a DATA statement the size of each string must match the size of the data type.
END</syntaxhighlight>Rather more changes are needed to produce the same result, in particular we cannot modify the format specifier directly and have to rely on overlaying it with an integer array and calculating the ASCII values needed for each byte we need to modify. Nested implicit DO loops are allowed, but not used as it isn't possible to compute K on the fly so we have to calculate (and store) the results for each row before printing it. Note also that the unit numbers for the output devices are different and when using Hollerith strings to define values in a DATA statement the size of each string must match the size of the data type.


===Microsoft FORTRAN-80===
===Microsoft FORTRAN-80===
The use of a non standard(?) BYTE data type available in Microsoft FORTRAN-80 makes it easier to understand what is going on.
The use of a non standard(?) BYTE data type available in Microsoft FORTRAN-80 makes it easier to understand what is going on.
<lang Fortran> PROGRAM TABLES
<syntaxhighlight lang=Fortran> PROGRAM TABLES
C
C
C Produce a formatted multiplication table of the kind memorised by rote
C Produce a formatted multiplication table of the kind memorised by rote
Line 4,062: Line 4,062:
3 CONTINUE
3 CONTINUE
C
C
END</lang>Inserting the following two lines before the inner DO loop will print the format specifier used to print each row of the table.<lang Fortran> WRITE(1,4) (A(J), J = 1,24)
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)</lang>Running the program produces the following output<lang>
4 FORMAT(1x,24A1)</syntaxhighlight>Running the program produces the following output<syntaxhighlight>
| 1 2 3 4 5 6 7 8 9 10 11 12
| 1 2 3 4 5 6 7 8 9 10 11 12
--+------------------------------------------------
--+------------------------------------------------
Line 4,077: Line 4,077:
10| 100 110 120
10| 100 110 120
11| 121 132
11| 121 132
12| 144</lang>
12| 144</syntaxhighlight>


=={{header|Frink}}==
=={{header|Frink}}==
<lang frink>a = makeArray[[13,13], {|a,b| a==0 ? b : (b==0 ? a : (a<=b ? a*b : ""))}]
<syntaxhighlight lang=frink>a = makeArray[[13,13], {|a,b| a==0 ? b : (b==0 ? a : (a<=b ? a*b : ""))}]
formatTable[a,"right"]</lang>
formatTable[a,"right"]</syntaxhighlight>


{{out}}
{{out}}
Line 4,102: Line 4,102:
=={{header|Gambas}}==
=={{header|Gambas}}==
'''[https://gambas-playground.proko.eu/?gist=3a3a987766a9a9a383b3e0e8a65d9ea2 Click this link to run this code]'''
'''[https://gambas-playground.proko.eu/?gist=3a3a987766a9a9a383b3e0e8a65d9ea2 Click this link to run this code]'''
<lang gambas>'Code 'stolen' from Free Basic and altered to work in Gambas
<syntaxhighlight lang=gambas>'Code 'stolen' from Free Basic and altered to work in Gambas


Public Sub Main()
Public Sub Main()
Line 4,124: Line 4,124:
Next
Next


End</lang>
End</syntaxhighlight>
Output:
Output:
<pre>
<pre>
Line 4,144: Line 4,144:


=={{header|Go}}==
=={{header|Go}}==
<syntaxhighlight lang=go>
<lang go>
package main
package main


Line 4,172: Line 4,172:
fmt.Println("")
fmt.Println("")
}
}
</syntaxhighlight>
</lang>


=={{header|Groovy}}==
=={{header|Groovy}}==
Solution:
Solution:
<lang groovy>def printMultTable = { size = 12 ->
<syntaxhighlight lang=groovy>def printMultTable = { size = 12 ->
assert size > 1
assert size > 1
Line 4,194: Line 4,194:
}
}


printMultTable()</lang>
printMultTable()</syntaxhighlight>


{{out}}
{{out}}
Line 4,214: Line 4,214:


=={{header|Haskell}}==
=={{header|Haskell}}==
<lang haskell>import Data.Maybe (fromMaybe, maybe)
<syntaxhighlight lang=haskell>import Data.Maybe (fromMaybe, maybe)


------------------- MULTIPLICATION TABLE -----------------
------------------- MULTIPLICATION TABLE -----------------
Line 4,249: Line 4,249:
gap = replicate w ' '
gap = replicate w ' '
rows = (maybe gap (rjust w ' ' . show) =<<) <$> xs
rows = (maybe gap (rjust w ' ' . show) =<<) <$> xs
rjust n c = (drop . length) <*> (replicate n c <>)</lang>
rjust n c = (drop . length) <*> (replicate n c <>)</syntaxhighlight>
{{Out}}
{{Out}}
<pre> 13 14 15 16 17 18 19 20
<pre> 13 14 15 16 17 18 19 20
Line 4,287: Line 4,287:


Or, more roughly and directly:
Or, more roughly and directly:
<lang haskell>import Data.List (groupBy)
<syntaxhighlight lang=haskell>import Data.List (groupBy)
import Data.Function (on)
import Data.Function (on)
import Control.Monad (join)
import Control.Monad (join)
Line 4,297: Line 4,297:
groupBy
groupBy
(on (==) fst)
(on (==) fst)
(filter (uncurry (>=)) $ join ((<*>) . fmap (,)) [1 .. 12])</lang>
(filter (uncurry (>=)) $ join ((<*>) . fmap (,)) [1 .. 12])</syntaxhighlight>
{{Out}}
{{Out}}
<pre>[1]
<pre>[1]
Line 4,313: Line 4,313:


=={{header|hexiscript}}==
=={{header|hexiscript}}==
<lang hexiscript>fun format n l
<syntaxhighlight lang=hexiscript>fun format n l
let n tostr n
let n tostr n
while len n < l; let n (" " + n); endwhile
while len n < l; let n (" " + n); endwhile
Line 4,331: Line 4,331:
endfor
endfor
println ""
println ""
endfor</lang>
endfor</syntaxhighlight>


=={{header|HicEst}}==
=={{header|HicEst}}==
<lang HicEst>WRITE(Row=1) " x 1 2 3 4 5 6 7 8 9 10 11 12"
<syntaxhighlight lang=HicEst>WRITE(Row=1) " x 1 2 3 4 5 6 7 8 9 10 11 12"
DO line = 1, 12
DO line = 1, 12
WRITE(Row=line+2, Format='i2') line
WRITE(Row=line+2, Format='i2') line
Line 4,340: Line 4,340:
WRITE(Row=line+2, Column=4*col, Format='i3') line*col
WRITE(Row=line+2, Column=4*col, Format='i3') line*col
ENDDO
ENDDO
ENDDO</lang>
ENDDO</syntaxhighlight>


=={{header|HolyC}}==
=={{header|HolyC}}==
{{trans|C}}
{{trans|C}}
<lang holyc>U8 i, j, n = 12;
<syntaxhighlight lang=holyc>U8 i, j, n = 12;
for (j = 1; j <= n; j++)
for (j = 1; j <= n; j++)
if (j != n)
if (j != n)
Line 4,364: Line 4,364:
Print("%3d ", i * j);
Print("%3d ", i * j);
Print("| %d\n", i);
Print("| %d\n", i);
}</lang>
}</syntaxhighlight>


=={{header|Icon}} and {{header|Unicon}}==
=={{header|Icon}} and {{header|Unicon}}==
<lang Icon>procedure main()
<syntaxhighlight lang=Icon>procedure main()
lim := 13
lim := 13
wid := 5
wid := 5
Line 4,373: Line 4,373:
every (i := 1 to lim) &
every (i := 1 to lim) &
writes(right( i||" |" | (j := 1 to lim, if j < i then "" else i*j) | "\n",wid)) # table content and triangle
writes(right( i||" |" | (j := 1 to lim, if j < i then "" else i*j) | "\n",wid)) # table content and triangle
end </lang>
end </syntaxhighlight>


The above example is a somewhat exaggerated example of contractions.
The above example is a somewhat exaggerated example of contractions.
Line 4,397: Line 4,397:


=={{header|J}}==
=={{header|J}}==
<lang j> multtable=: <:/~ * */~
<syntaxhighlight lang=j> multtable=: <:/~ * */~
format=: 'b4.0' 8!:2 ]
format=: 'b4.0' 8!:2 ]
(('*' ; ,.) ,. ({. ; ])@format@multtable) >:i.12
(('*' ; ,.) ,. ({. ; ])@format@multtable) >:i.12
Line 4,415: Line 4,415:
│11│ 121 132│
│11│ 121 132│
│12│ 144│
│12│ 144│
└──┴────────────────────────────────────────────────┘</lang>
└──┴────────────────────────────────────────────────┘</syntaxhighlight>


That said, note that <code>*/~</code> is the core primitive used to construct a multiplication table and this is a general technique so that, for example, <code>+/~</code> would make an addition table. The rest is just to make it look pretty (and to blank out the lower triangle -- we use a less than or equal table (<code><:/~</code>) to control that, and format zeros as spaces to blank them out).
That said, note that <code>*/~</code> is the core primitive used to construct a multiplication table and this is a general technique so that, for example, <code>+/~</code> would make an addition table. The rest is just to make it look pretty (and to blank out the lower triangle -- we use a less than or equal table (<code><:/~</code>) to control that, and format zeros as spaces to blank them out).


=={{header|Java}}==
=={{header|Java}}==
<lang Java>public class MultiplicationTable {
<syntaxhighlight lang=Java>public class MultiplicationTable {
public static void main(String[] args) {
public static void main(String[] args) {
for (int i = 1; i <= 12; i++)
for (int i = 1; i <= 12; i++)
Line 4,439: Line 4,439:
}
}
}
}
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 4,462: Line 4,462:
===Imperative===
===Imperative===


<lang html4strict><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<syntaxhighlight lang=html4strict><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<head>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
Line 4,513: Line 4,513:
<div id='target'></div>
<div id='target'></div>
</body>
</body>
</html></lang>
</html></syntaxhighlight>


{{out}} (minus the style):
{{out}} (minus the style):
Line 4,520: Line 4,520:
===Functional===
===Functional===
====ES5====
====ES5====
<lang JavaScript>(function (m, n) {
<syntaxhighlight lang=JavaScript>(function (m, n) {
// [m..n]
// [m..n]
Line 4,568: Line 4,568:
JSON.stringify(lstTable);
JSON.stringify(lstTable);
})(1, 12);</lang>
})(1, 12);</syntaxhighlight>


{{out}}
{{out}}
Line 4,601: Line 4,601:
|}
|}


<lang JavaScript>[["x",1,2,3,4,5,6,7,8,9,10,11,12],
<syntaxhighlight lang=JavaScript>[["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],
[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],
[2,"",4,6,8,10,12,14,16,18,20,22,24],
Line 4,613: Line 4,613:
[10,"","","","","","","","","",100,110,120],
[10,"","","","","","","","","",100,110,120],
[11,"","","","","","","","","","",121,132],
[11,"","","","","","","","","","",121,132],
[12,"","","","","","","","","","","",144]]</lang>
[12,"","","","","","","","","","","",144]]</syntaxhighlight>


====ES6====
====ES6====
<lang JavaScript>(() => {
<syntaxhighlight lang=JavaScript>(() => {
"use strict";
"use strict";


Line 4,689: Line 4,689:
// MAIN ---
// MAIN ---
return main();
return main();
})();</lang>
})();</syntaxhighlight>
{{Out}}
{{Out}}
{| class="wikitable" style="text-align:center;width:33em;height:33em;table-layout:fixed"
{| class="wikitable" style="text-align:center;width:33em;height:33em;table-layout:fixed"
Line 4,720: Line 4,720:


=={{header|Jsish}}==
=={{header|Jsish}}==
<lang javascript>/* Multiplication tables, is Jsish */
<syntaxhighlight lang=javascript>/* Multiplication tables, is Jsish */
var m, n, tableSize = 12;
var m, n, tableSize = 12;


Line 4,740: Line 4,740:
}
}
}
}
printf('\n');</lang>
printf('\n');</syntaxhighlight>


{{out}}
{{out}}
Line 4,768: Line 4,768:


=={{header|Julia}}==
=={{header|Julia}}==
<lang Julia>using Printf
<syntaxhighlight lang=Julia>using Printf


println(" X | 1 2 3 4 5 6 7 8 9 10 11 12")
println(" X | 1 2 3 4 5 6 7 8 9 10 11 12")
Line 4,781: Line 4,781:
print(" ")
print(" ")
end
end
end</lang>
end</syntaxhighlight>


{{out}}
{{out}}
Line 4,800: Line 4,800:


=={{header|Kotlin}}==
=={{header|Kotlin}}==
<lang scala>// version 1.0.6
<syntaxhighlight lang=scala>// version 1.0.6


fun main(args: Array<String>) {
fun main(args: Array<String>) {
Line 4,811: Line 4,811:
println()
println()
}
}
}</lang>
}</syntaxhighlight>


{{out}}
{{out}}
Line 4,835: Line 4,835:
Outputs are visible in http://lambdaway.free.fr/lambdawalks/?view=multiplication_table
Outputs are visible in http://lambdaway.free.fr/lambdawalks/?view=multiplication_table


<lang scheme>
<syntaxhighlight lang=scheme>
{def format
{def format
{lambda {:w :c}
{lambda {:w :c}
Line 4,876: Line 4,876:
3) {make_table {operation pow} 6 10}
3) {make_table {operation pow} 6 10}


</syntaxhighlight>
</lang>


=={{header|Lasso}}==
=={{header|Lasso}}==
<lang lasso>define printTimesTables(max::integer) => {
<syntaxhighlight lang=lasso>define printTimesTables(max::integer) => {
local(result) = ``
local(result) = ``
local(padSize) = string(#max*#max)->size + 1
local(padSize) = string(#max*#max)->size + 1
Line 4,907: Line 4,907:
}
}


printTimesTables(12)</lang>
printTimesTables(12)</syntaxhighlight>


{{out}}
{{out}}
Line 4,927: Line 4,927:
=={{header|Logo}}==
=={{header|Logo}}==
{{works with|UCB Logo}}
{{works with|UCB Logo}}
<lang logo>to mult.table :n
<syntaxhighlight lang=logo>to mult.table :n
type "| | for [i 2 :n] [type form :i 4 0] (print)
type "| | for [i 2 :n] [type form :i 4 0] (print)
(print)
(print)
Line 4,940: Line 4,940:


mult.table 12
mult.table 12
</syntaxhighlight>
</lang>


=={{header|Lua}}==
=={{header|Lua}}==
<lang lua>io.write( " |" )
<syntaxhighlight lang=lua>io.write( " |" )
for i = 1, 12 do
for i = 1, 12 do
io.write( string.format( "%#5d", i ) )
io.write( string.format( "%#5d", i ) )
Line 4,960: Line 4,960:
end
end
io.write( "\n" )
io.write( "\n" )
end</lang>
end</syntaxhighlight>
<pre> | 1 2 3 4 5 6 7 8 9 10 11 12
<pre> | 1 2 3 4 5 6 7 8 9 10 11 12
----------------------------------------------------------------
----------------------------------------------------------------
Line 4,978: Line 4,978:
=={{header|M2000 Interpreter}}==
=={{header|M2000 Interpreter}}==
Using jagged array (arrays of arrays)
Using jagged array (arrays of arrays)
<lang M2000 Interpreter>
<syntaxhighlight lang=M2000 Interpreter>
Module CheckIt {
Module CheckIt {
Dim Base 1, A(12)
Dim Base 1, A(12)
Line 5,005: Line 5,005:
}
}
CheckIt
CheckIt
</syntaxhighlight>
</lang>


Final loop can be this, using Each() and r1 as pointer to array.
Final loop can be this, using Each() and r1 as pointer to array.
Line 5,040: Line 5,040:


=={{header|Maple}}==
=={{header|Maple}}==
<lang maple>printf(" ");
<syntaxhighlight lang=maple>printf(" ");
for i to 12 do
for i to 12 do
printf("%-3d ", i);
printf("%-3d ", i);
Line 5,057: Line 5,057:
end if
end if
end do
end do
end do</lang>
end do</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 5,077: Line 5,077:


=={{header|Mathematica}}/{{header|Wolfram Language}}==
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<lang Mathematica>Grid[{{Range[12]//Column,Grid[UpperTriangularize[KroneckerProduct[Range[12],Range[12]]]/.{0->""}]}}]</lang>
<syntaxhighlight lang=Mathematica>Grid[{{Range[12]//Column,Grid[UpperTriangularize[KroneckerProduct[Range[12],Range[12]]]/.{0->""}]}}]</syntaxhighlight>
{{out}}
{{out}}
<pre>1 1 2 3 4 5 6 7 8 9 10 11 12
<pre>1 1 2 3 4 5 6 7 8 9 10 11 12
Line 5,095: Line 5,095:
timesTable.m: (creates Times Table of N degree)
timesTable.m: (creates Times Table of N degree)


<lang MATLAB>function table = timesTable(N)
<syntaxhighlight lang=MATLAB>function table = timesTable(N)
table = [(0:N); (1:N)' triu( kron((1:N),(1:N)') )];
table = [(0:N); (1:N)' triu( kron((1:N),(1:N)') )];
end</lang>
end</syntaxhighlight>


A minimally vectorized version of the above code:
A minimally vectorized version of the above code:


<lang MATLAB>function table = timesTable(N)
<syntaxhighlight lang=MATLAB>function table = timesTable(N)


%Generates a column vector with integers from 1 to N
%Generates a column vector with integers from 1 to N
Line 5,117: Line 5,117:
table = [columnLabels; rowLabels triu(table)];
table = [columnLabels; rowLabels triu(table)];
end</lang>
end</syntaxhighlight>
{{out}}
{{out}}
Line 5,141: Line 5,141:


=={{header|Maxima}}==
=={{header|Maxima}}==
<lang Maxima>for i: 1 thru 12 do (
<syntaxhighlight lang=Maxima>for i: 1 thru 12 do (
for j: 1 thru 12 do (
for j: 1 thru 12 do (
if j>=i or j=1 then printf(true, "~4d", i*j) else printf(true, " ")
if j>=i or j=1 then printf(true, "~4d", i*j) else printf(true, " ")
),
),
printf(true, "~%")
printf(true, "~%")
);</lang>
);</syntaxhighlight>




=={{header|МК-61/52}}==
=={{header|МК-61/52}}==
<lang>П0 КИП0 КИП4 КИП5 ИП4 ИП5 * С/П
<syntaxhighlight>П0 КИП0 КИП4 КИП5 ИП4 ИП5 * С/П
ИП5 ИП0 - x=0 03
ИП5 ИП0 - x=0 03
ИП4 ИП0 - x#0 22 ИП4 П5 БП 02
ИП4 ИП0 - x#0 22 ИП4 П5 БП 02
С/П</lang>
С/П</syntaxhighlight>


''Input'': 12 С/П ...
''Input'': 12 С/П ...
Line 5,175: Line 5,175:
=={{header|Modula-2}}==
=={{header|Modula-2}}==
{{works with|ADW Modula-2|any (Compile with the linker option ''Console Application'').}}
{{works with|ADW Modula-2|any (Compile with the linker option ''Console Application'').}}
<lang modula2>
<syntaxhighlight lang=modula2>
MODULE MultiplicationTables;
MODULE MultiplicationTables;


Line 5,215: Line 5,215:
END;
END;
END MultiplicationTables.
END MultiplicationTables.
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>
<pre>
Line 5,236: Line 5,236:
=={{header|MOO}}==
=={{header|MOO}}==
This quick example is designed to demonstrate raw MOO. In other words it does not use any of the helper functions available in popular DBs such as LambdaMOO.
This quick example is designed to demonstrate raw MOO. In other words it does not use any of the helper functions available in popular DBs such as LambdaMOO.
<lang moo>
<syntaxhighlight lang=moo>
@verb me:@tables none none none rxd
@verb me:@tables none none none rxd
@program me:@tables
@program me:@tables
Line 5,262: Line 5,262:
endfor
endfor
.
.
</syntaxhighlight>
</lang>


LambdaMOO string utilities version:
LambdaMOO string utilities version:
<lang moo>
<syntaxhighlight lang=moo>
@program me:@tables
@program me:@tables
player:tell(" | 1 2 3 4 5 6 7 8 9 10 11 12");
player:tell(" | 1 2 3 4 5 6 7 8 9 10 11 12");
Line 5,277: Line 5,277:
endfor
endfor
.
.
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>
<pre>
Line 5,298: Line 5,298:


=={{header|MUMPS}}==
=={{header|MUMPS}}==
<lang MUMPS>MULTTABLE(SIZE)
<syntaxhighlight lang=MUMPS>MULTTABLE(SIZE)
;Print out a multiplication table
;Print out a multiplication table
;SIZE is the size of the multiplication table to make
;SIZE is the size of the multiplication table to make
Line 5,318: Line 5,318:
..WRITE:((A-1)>=(D-2))&((D-2)>=1) ?((A-1)*5),$JUSTIFY((D-2)*(A-1),MW)
..WRITE:((A-1)>=(D-2))&((D-2)>=1) ?((A-1)*5),$JUSTIFY((D-2)*(A-1),MW)
KILL MW,D,A,BAR
KILL MW,D,A,BAR
QUIT</lang>
QUIT</syntaxhighlight>


{{out}}
{{out}}
Line 5,339: Line 5,339:


=={{header|Neko}}==
=={{header|Neko}}==
<lang ActionScript>/**
<syntaxhighlight lang=ActionScript>/**
Multiplication table, in Neko
Multiplication table, in Neko
Tectonics:
Tectonics:
Line 5,380: Line 5,380:
$print("\n");
$print("\n");
j += 1;
j += 1;
}</lang>
}</syntaxhighlight>


{{out}}
{{out}}
Line 5,403: Line 5,403:
=={{header|Nim}}==
=={{header|Nim}}==
{{trans|C}}
{{trans|C}}
<lang nim>import strfmt
<syntaxhighlight lang=nim>import strfmt


const n = 12
const n = 12
Line 5,414: Line 5,414:
for j in 1..n:
for j in 1..n:
stdout.write if j<i: " " else: "{:3d} ".fmt(i*j)
stdout.write if j<i: " " else: "{:3d} ".fmt(i*j)
echo "| {:2d}".fmt(i)</lang>
echo "| {:2d}".fmt(i)</syntaxhighlight>
{{out}}
{{out}}
<pre> 1 2 3 4 5 6 7 8 9 10 11 12
<pre> 1 2 3 4 5 6 7 8 9 10 11 12
Line 5,434: Line 5,434:
{{trans|C}}
{{trans|C}}


<lang ocaml>let () =
<syntaxhighlight lang=ocaml>let () =
let max = 12 in
let max = 12 in
let fmax = float_of_int max in
let fmax = float_of_int max in
Line 5,452: Line 5,452:
print_newline()
print_newline()
done;
done;
print_newline()</lang>
print_newline()</syntaxhighlight>


=={{header|PARI/GP}}==
=={{header|PARI/GP}}==
Quick and dirty one-liner:
Quick and dirty one-liner:
<lang parigp>for(y=1,12,printf("%2Ps| ",y);for(x=1,12,print1(if(y>x,"",x*y)"\t"));print)</lang>
<syntaxhighlight lang=parigp>for(y=1,12,printf("%2Ps| ",y);for(x=1,12,print1(if(y>x,"",x*y)"\t"));print)</syntaxhighlight>


=={{header|Pascal}}==
=={{header|Pascal}}==
Line 5,462: Line 5,462:


=={{header|Perl}}==
=={{header|Perl}}==
<lang perl>our $max = 12;
<syntaxhighlight lang=perl>our $max = 12;
our $width = length($max**2) + 1;
our $width = length($max**2) + 1;


Line 5,471: Line 5,471:
foreach "$i|", map { $_ >= $i and $_*$i } 1..$max;
foreach "$i|", map { $_ >= $i and $_*$i } 1..$max;
print "\n";
print "\n";
}</lang>
}</syntaxhighlight>


{{out}}
{{out}}
Line 5,493: Line 5,493:
=={{header|Phix}}==
=={{header|Phix}}==
{{Trans|Ada}}
{{Trans|Ada}}
<!--<lang Phix>(phixonline)-->
<!--<syntaxhighlight lang=Phix>(phixonline)-->
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">" | "</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">" | "</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">for</span> <span style="color: #000000;">col</span><span style="color: #0000FF;">=</span><span style="color: #000000;">1</span> <span style="color: #008080;">to</span> <span style="color: #000000;">12</span> <span style="color: #008080;">do</span>
<span style="color: #008080;">for</span> <span style="color: #000000;">col</span><span style="color: #0000FF;">=</span><span style="color: #000000;">1</span> <span style="color: #008080;">to</span> <span style="color: #000000;">12</span> <span style="color: #008080;">do</span>
Line 5,505: Line 5,505:
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<!--</lang>-->
<!--</syntaxhighlight>-->
{{out}}
{{out}}
<pre style="font-size: 8px">
<pre style="font-size: 8px">
Line 5,525: Line 5,525:


=={{header|Picat}}==
=={{header|Picat}}==
<lang Picat>go =>
<syntaxhighlight lang=Picat>go =>
N=12,
N=12,
make_table(N),
make_table(N),
Line 5,549: Line 5,549:
nl
nl
end,
end,
nl.</lang>
nl.</syntaxhighlight>


{{out}}
{{out}}
Line 5,569: Line 5,569:


=={{header|PicoLisp}}==
=={{header|PicoLisp}}==
<lang PicoLi/th>sp>(de mulTable (N)
<syntaxhighlight lang=PicoLi/th>sp>(de mulTable (N)
(space 4)
(space 4)
(for X N
(for X N
Line 5,582: Line 5,582:
(prinl) ) )
(prinl) ) )


(mulTable 12)</lang>
(mulTable 12)</syntaxhighlight>
{{out}}
{{out}}
<pre> 1 2 3 4 5 6 7 8 9 10 11 12
<pre> 1 2 3 4 5 6 7 8 9 10 11 12
Line 5,600: Line 5,600:


=={{header|PL/I}}==
=={{header|PL/I}}==
<lang PL/I>
<syntaxhighlight lang=PL/I>
/* 12 x 12 multiplication table. */
/* 12 x 12 multiplication table. */


Line 5,615: Line 5,615:


end multiplication_table;
end multiplication_table;
</syntaxhighlight>
</lang>


Result:
Result:


<syntaxhighlight>
<lang>
1 2 3 4 5 6 7 8 9 10 11 12
1 2 3 4 5 6 7 8 9 10 11 12
_________________________________________________
_________________________________________________
Line 5,634: Line 5,634:
11 | 121 132
11 | 121 132
12 | 144
12 | 144
</syntaxhighlight>
</lang>


=={{header|PowerShell}}==
=={{header|PowerShell}}==
<lang powershell># For clarity
<syntaxhighlight lang=powershell># For clarity
$Tab = "`t"
$Tab = "`t"
Line 5,657: Line 5,657:
# Combine them all together
# Combine them all together
) -join $Tab
) -join $Tab
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre> 1 2 3 4 5 6 7 8 9 10 11 12
<pre> 1 2 3 4 5 6 7 8 9 10 11 12
Line 5,673: Line 5,673:
12 144</pre>
12 144</pre>
<b>A more general solution</b>
<b>A more general solution</b>
<lang powershell>function Get-TimesTable ( [int]$Size )
<syntaxhighlight lang=powershell>function Get-TimesTable ( [int]$Size )
{
{
# For clarity
# For clarity
Line 5,698: Line 5,698:
}
}
Get-TimesTable 18</lang>
Get-TimesTable 18</syntaxhighlight>
{{out}}
{{out}}
<pre> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
<pre> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
Line 5,721: Line 5,721:


=={{header|Prolog}}==
=={{header|Prolog}}==
<lang prolog>make_table(S,E) :-
<syntaxhighlight lang=prolog>make_table(S,E) :-
print_header(S,E),
print_header(S,E),
make_table_rows(S,E),
make_table_rows(S,E),
Line 5,753: Line 5,753:
print_num(X) :- X < 10, format(' ~p', X).
print_num(X) :- X < 10, format(' ~p', X).
print_num(X) :- between(10,99,X), format(' ~p', X).
print_num(X) :- between(10,99,X), format(' ~p', X).
print_num(X) :- X > 99, format(' ~p', X).</lang>
print_num(X) :- X > 99, format(' ~p', X).</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 5,778: Line 5,778:
=={{header|Python}}==
=={{header|Python}}==
===Procedural===
===Procedural===
<lang python>>>> size = 12
<syntaxhighlight lang=python>>>> size = 12
>>> width = len(str(size**2))
>>> width = len(str(size**2))
>>> for row in range(-1,size+1):
>>> for row in range(-1,size+1):
Line 5,806: Line 5,806:
11│ 121 132
11│ 121 132
12│ 144
12│ 144
>>> </lang>
>>> </syntaxhighlight>


The above works with Python 3.X, which uses Unicode strings by default. <br>
The above works with Python 3.X, which uses Unicode strings by default. <br>
Line 5,818: Line 5,818:
and then again, for comparison, as an equivalent '''list monad''' expression (''mulTable2'' function):
and then again, for comparison, as an equivalent '''list monad''' expression (''mulTable2'' function):


<lang python>'''Multiplication table
<syntaxhighlight lang=python>'''Multiplication table


1. by list comprehension (mulTable ),
1. by list comprehension (mulTable ),
Line 5,920: Line 5,920:


if __name__ == '__main__':
if __name__ == '__main__':
main()</lang>
main()</syntaxhighlight>
{{Out}}
{{Out}}
<pre>By list comprehension (mulTable):
<pre>By list comprehension (mulTable):
Line 5,956: Line 5,956:
{{Trans|Haskell}}
{{Trans|Haskell}}
{{Works with|Python|3.7}}
{{Works with|Python|3.7}}
<lang python>'''Generalised multiplication tables'''
<syntaxhighlight lang=python>'''Generalised multiplication tables'''


import collections
import collections
Line 6,222: Line 6,222:
# MAIN ---
# MAIN ---
if __name__ == '__main__':
if __name__ == '__main__':
main()</lang>
main()</syntaxhighlight>
{{Out}}
{{Out}}
<pre> 13 14 15 16 17 18 19 20
<pre> 13 14 15 16 17 18 19 20
Line 6,262: Line 6,262:
=={{header|Quackery}}==
=={{header|Quackery}}==


<lang Quackery> [ swap number$
<syntaxhighlight lang=Quackery> [ swap number$
tuck size -
tuck size -
times sp echo$ ] is echo-rj ( n n --> )
times sp echo$ ] is echo-rj ( n n --> )
Line 6,281: Line 6,281:
[ dip dup
[ dip dup
* 4 echo-rj ] ]
* 4 echo-rj ] ]
cr drop ] ]</lang>
cr drop ] ]</syntaxhighlight>


{{Out}}
{{Out}}
Line 6,301: Line 6,301:


=={{header|R}}==
=={{header|R}}==
<syntaxhighlight lang=r>
<lang r>
multiplication_table <- function(n=12)
multiplication_table <- function(n=12)
{
{
Line 6,312: Line 6,312:
}
}
multiplication_table()
multiplication_table()
</syntaxhighlight>
</lang>


=={{header|Racket}}==
=={{header|Racket}}==


<lang Racket>
<syntaxhighlight lang=Racket>
#lang racket
#lang racket


Line 6,327: Line 6,327:
(show-line (cons y (for/list ([x (in-range 1 13)])
(show-line (cons y (for/list ([x (in-range 1 13)])
(if (<= y x) (* x y) "")))))
(if (<= y x) (* x y) "")))))
</syntaxhighlight>
</lang>


{{out}}
{{out}}
Line 6,348: Line 6,348:
=={{header|Raku}}==
=={{header|Raku}}==
(formerly Perl 6)
(formerly Perl 6)
<lang perl6>(my $f = "%{$_}s" given my $width = ($_**2).chars ) given my $max = 12;
<syntaxhighlight lang=perl6>(my $f = "%{$_}s" given my $width = ($_**2).chars ) given my $max = 12;


say '×'.fmt($f) ~ ' ┃ ' ~ (1..$max).fmt($f);
say '×'.fmt($f) ~ ' ┃ ' ~ (1..$max).fmt($f);
Line 6,355: Line 6,355:
for 1..$max -> $i {
for 1..$max -> $i {
say $i.fmt($f) ~ ' ┃ ' ~ ( $i ≤ $_ ?? $i×$_ !! '' for 1..$max ).fmt($f);
say $i.fmt($f) ~ ' ┃ ' ~ ( $i ≤ $_ ?? $i×$_ !! '' for 1..$max ).fmt($f);
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 6,375: Line 6,375:


=={{header|REBOL}}==
=={{header|REBOL}}==
<lang REBOL>REBOL [
<syntaxhighlight lang=REBOL>REBOL [
Title: "12x12 Multiplication Table"
Title: "12x12 Multiplication Table"
URL: http://rosettacode.org/wiki/Print_a_Multiplication_Table
URL: http://rosettacode.org/wiki/Print_a_Multiplication_Table
Line 6,407: Line 6,407:


print rejoin [ crlf "How about " size: 20 "?" crlf ]
print rejoin [ crlf "How about " size: 20 "?" crlf ]
-- .row " x " 1 -- repeat y size [.row p3 y y] --</lang>
-- .row " x " 1 -- repeat y size [.row p3 y y] --</syntaxhighlight>


{{out}} (only 12x12 shown):
{{out}} (only 12x12 shown):
Line 6,429: Line 6,429:


=={{header|REXX}}==
=={{header|REXX}}==
<lang REXX>/*REXX program displays a NxN multiplication table (in a boxed grid) to the terminal.*/
<syntaxhighlight lang=REXX>/*REXX program displays a NxN multiplication table (in a boxed grid) to the terminal.*/
parse arg sz . /*obtain optional argument from the CL.*/
parse arg sz . /*obtain optional argument from the CL.*/
if sz=='' | sz=="," then sz= 12 /*Not specified? Then use the default.*/
if sz=='' | sz=="," then sz= 12 /*Not specified? Then use the default.*/
Line 6,451: Line 6,451:
top: $= '┌'__"┬"copies(___'┬', sz); call dap "┐"; ?= arg(1); say $; call hdr; return
top: $= '┌'__"┬"copies(___'┬', sz); call dap "┐"; ?= arg(1); say $; call hdr; return
sep: $= '├'__"┼"copies(___'┼', sz); call dap "┤"; say $; return
sep: $= '├'__"┼"copies(___'┼', sz); call dap "┤"; say $; return
bot: $= '└'__"┴"copies(___'┴', sz); call dap "┘"; say $; return</lang>
bot: $= '└'__"┴"copies(___'┴', sz); call dap "┘"; say $; return</syntaxhighlight>
{{out|output|text=&nbsp; when using the default input of: &nbsp; &nbsp; <tt> 12 </tt>}}
{{out|output|text=&nbsp; when using the default input of: &nbsp; &nbsp; <tt> 12 </tt>}}
<pre>
<pre>
Line 6,523: Line 6,523:


=={{header|Ring}}==
=={{header|Ring}}==
<lang ring>
<syntaxhighlight lang=ring>
multiplication_table(12)
multiplication_table(12)
func multiplication_table n
func multiplication_table n
Line 6,535: Line 6,535:
next
next
func fsize x,n return string(x) + copy(" ",n-len(string(x)))
func fsize x,n return string(x) + copy(" ",n-len(string(x)))
</syntaxhighlight>
</lang>


Output
Output
<lang ring>
<syntaxhighlight lang=ring>
| 1 2 3 4 5 6 7 8 9 10 11 12
| 1 2 3 4 5 6 7 8 9 10 11 12
----+-------------------------------------------------
----+-------------------------------------------------
Line 6,553: Line 6,553:
11 | 121 132
11 | 121 132
12 | 144
12 | 144
</syntaxhighlight>
</lang>


=={{header|Ruby}}==
=={{header|Ruby}}==
<lang ruby>def multiplication_table(n)
<syntaxhighlight lang=ruby>def multiplication_table(n)
puts " |" + (" %3d" * n) % [*1..n]
puts " |" + (" %3d" * n) % [*1..n]
puts "----+" + "----" * n
puts "----+" + "----" * n
Line 6,567: Line 6,567:
end
end


multiplication_table 12</lang>
multiplication_table 12</syntaxhighlight>


{{out}}
{{out}}
Line 6,588: Line 6,588:


=={{header|Rust}}==
=={{header|Rust}}==
<lang rust>const LIMIT: i32 = 12;
<syntaxhighlight lang=rust>const LIMIT: i32 = 12;


fn main() {
fn main() {
Line 6,608: Line 6,608:
println!("| {}", i);
println!("| {}", i);
}
}
}</lang>
}</syntaxhighlight>


or, in terms of map:
or, in terms of map:


<lang rust>fn main() {
<syntaxhighlight lang=rust>fn main() {
let xs = (1..=12)
let xs = (1..=12)
.map(|a| {
.map(|a| {
Line 6,628: Line 6,628:


println!("{}", xs.join("\n"))
println!("{}", xs.join("\n"))
}</lang>
}</syntaxhighlight>


=={{header|Scala}}==
=={{header|Scala}}==
<lang scala>
<syntaxhighlight lang=scala>
//Multiplication Table
//Multiplication Table
print("%5s".format("|"))
print("%5s".format("|"))
Line 6,650: Line 6,650:
println("")
println("")
}
}
</syntaxhighlight>
</lang>


=== case ===
=== case ===
<lang scala>
<syntaxhighlight lang=scala>
implicit def intToString(i: Int) = i.toString
implicit def intToString(i: Int) = i.toString
val cell = (x:String) => print("%5s".format(x))
val cell = (x:String) => print("%5s".format(x))
Line 6,672: Line 6,672:
}
}
}
}
</syntaxhighlight>
</lang>


=={{header|Scheme}}==
=={{header|Scheme}}==
Line 6,678: Line 6,678:
A better implementation of <tt>iota</tt> is provided by SRFI-1 [http://srfi.schemers.org/srfi-1/srfi-1.html].
A better implementation of <tt>iota</tt> is provided by SRFI-1 [http://srfi.schemers.org/srfi-1/srfi-1.html].


<lang scheme>
<syntaxhighlight lang=scheme>
(define iota
(define iota
(lambda (count start step)
(lambda (count start step)
Line 6,705: Line 6,705:
(loop (+ count 1)
(loop (+ count 1)
(cdr numbers)))))))
(cdr numbers)))))))
</syntaxhighlight>
</lang>


<pre>
<pre>
Line 6,725: Line 6,725:
=={{header|Scilab}}==
=={{header|Scilab}}==
{{works with|Scilab|5.5.1}}
{{works with|Scilab|5.5.1}}
<lang> nmax=12, xx=3
<syntaxhighlight> nmax=12, xx=3
s= blanks(xx)+" |"
s= blanks(xx)+" |"
for j=1:nmax
for j=1:nmax
Line 6,746: Line 6,746:
end
end
printf("%s\n",s)
printf("%s\n",s)
end</lang>
end</syntaxhighlight>
{{out}}
{{out}}
<pre> | 1 2 3 4 5 6 7 8 9 10 11 12
<pre> | 1 2 3 4 5 6 7 8 9 10 11 12
Line 6,764: Line 6,764:


=={{header|Seed7}}==
=={{header|Seed7}}==
<lang seed7>$ include "seed7_05.s7i";
<syntaxhighlight lang=seed7>$ include "seed7_05.s7i";
const proc: main is func
const proc: main is func
Line 6,787: Line 6,787:
writeln("|" <& i lpad 3);
writeln("|" <& i lpad 3);
end for;
end for;
end func;</lang>
end func;</syntaxhighlight>


{{out}}
{{out}}
Line 6,808: Line 6,808:


=={{header|Sidef}}==
=={{header|Sidef}}==
<lang ruby>var max = 12
<syntaxhighlight lang=ruby>var max = 12
var width = (max**2 -> len+1)
var width = (max**2 -> len+1)
 
 
Line 6,820: Line 6,820:
{ |i| 
{ |i| 
say fmt_row("#{i}┃", {|j| i <= j ? i*j : ''}.map(1..max)...)
say fmt_row("#{i}┃", {|j| i <= j ? i*j : ''}.map(1..max)...)
} << 1..max</lang>
} << 1..max</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 6,841: Line 6,841:
=={{header|Simula}}==
=={{header|Simula}}==
{{trans|ALGOL W}}
{{trans|ALGOL W}}
<lang simula>begin
<syntaxhighlight lang=simula>begin
integer i, j;
integer i, j;
outtext( " " );
outtext( " " );
Line 6,857: Line 6,857:
outimage
outimage
end;
end;
end</lang>
end</syntaxhighlight>
{{out}}
{{out}}
<pre> 1 2 3 4 5 6 7 8 9 10 11 12
<pre> 1 2 3 4 5 6 7 8 9 10 11 12
Line 6,875: Line 6,875:


=={{header|Swift}}==
=={{header|Swift}}==
<lang swift>import Foundation
<syntaxhighlight lang=swift>import Foundation


let size = 12
let size = 12
Line 6,895: Line 6,895:
printRow( with: i, upto: size)
printRow( with: i, upto: size)
}
}
</syntaxhighlight>
</lang>


=={{header|Tailspin}}==
=={{header|Tailspin}}==
<lang tailspin>
<syntaxhighlight lang=tailspin>
templates formatN&{width:}
templates formatN&{width:}
[ 1..$width -> ' ', '$;'... ] -> '$(last-$width+1..last)...;' !
[ 1..$width -> ' ', '$;'... ] -> '$(last-$width+1..last)...;' !
Line 6,910: Line 6,910:
'$ -> formatN&{width:2};|$:1..($-1)*4 -> ' ';$:$..12 -> $*$row -> formatN&{width:4};
'$ -> formatN&{width:2};|$:1..($-1)*4 -> ' ';$:$..12 -> $*$row -> formatN&{width:4};
' ! \) -> !OUT::write
' ! \) -> !OUT::write
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>
<pre>
Line 6,930: Line 6,930:


=={{header|Tcl}}==
=={{header|Tcl}}==
<lang tcl>puts " x\u2502 1 2 3 4 5 6 7 8 9 10 11 12"
<syntaxhighlight lang=tcl>puts " x\u2502 1 2 3 4 5 6 7 8 9 10 11 12"
puts \u0020\u2500\u2500\u253c[string repeat \u2500 48]
puts \u0020\u2500\u2500\u253c[string repeat \u2500 48]
for {set i 1} {$i <= 12} {incr i} {
for {set i 1} {$i <= 12} {incr i} {
Line 6,940: Line 6,940:
}
}
puts ""
puts ""
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 6,960: Line 6,960:


=={{header|TUSCRIPT}}==
=={{header|TUSCRIPT}}==
<lang tuscript>
<syntaxhighlight lang=tuscript>
$$ MODE TUSCRIPT
$$ MODE TUSCRIPT
x=y="1'2'3'4'5'6'7'8'9'10'11'12"
x=y="1'2'3'4'5'6'7'8'9'10'11'12"
Line 6,979: Line 6,979:
PRINT col,cnt
PRINT col,cnt
ENDLOOP
ENDLOOP
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre style='height:30ex;overflow:scroll'>
<pre style='height:30ex;overflow:scroll'>
Line 6,998: Line 6,998:
== {{header|TypeScript}} ==
== {{header|TypeScript}} ==
{{trans|Modula-2}}
{{trans|Modula-2}}
<lang javascript>
<syntaxhighlight lang=javascript>
// Multiplication tables
// Multiplication tables


Line 7,013: Line 7,013:
console.log("| " + i.toString().padStart(2, ' '));
console.log("| " + i.toString().padStart(2, ' '));
}
}
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>
<pre>
Line 7,035: Line 7,035:
It's no more difficult to express the general case than the size 12 case, so
It's no more difficult to express the general case than the size 12 case, so
a table generating function parameterized by the size is used.
a table generating function parameterized by the size is used.
<lang Ursala>
<syntaxhighlight lang=Ursala>
#import std
#import std
#import nat
#import nat
Line 7,048: Line 7,048:


main = table 12
main = table 12
</syntaxhighlight>
</lang>
A better way of using Ursala to make tables would be with the <code>tbl</code> library included with
A better way of using Ursala to make tables would be with the <code>tbl</code> library included with
the standard package, which can generate LaTeX code for arbitrary heading hierarchies and typesetting options, but here it is in ASCII art.
the standard package, which can generate LaTeX code for arbitrary heading hierarchies and typesetting options, but here it is in ASCII art.
Line 7,070: Line 7,070:
=={{header|VBA}}==
=={{header|VBA}}==


<syntaxhighlight lang=vb>
<lang vb>
Option Explicit
Option Explicit


Line 7,100: Line 7,100:
Next i
Next i
End Sub
End Sub
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre> 1 2 3 4 5 6 7 8 9 10 11 12
<pre> 1 2 3 4 5 6 7 8 9 10 11 12
Line 7,118: Line 7,118:
=={{header|Wren}}==
=={{header|Wren}}==
{{libheader|Wren-fmt}}
{{libheader|Wren-fmt}}
<lang ecmascript>import "/fmt" for Fmt
<syntaxhighlight lang=ecmascript>import "/fmt" for Fmt


var nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
var nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
Line 7,126: Line 7,126:
var nums2 = nums.map { |n| (n >= i) ? (n * i).toString : " " }.toList
var nums2 = nums.map { |n| (n >= i) ? (n * i).toString : " " }.toList
Fmt.print("$3d | $4s", i, nums2)
Fmt.print("$3d | $4s", i, nums2)
}</lang>
}</syntaxhighlight>


{{out}}
{{out}}
Line 7,148: Line 7,148:


=={{header|XPL0}}==
=={{header|XPL0}}==
<lang XPL0>include c:\cxpl\codes;
<syntaxhighlight lang=XPL0>include c:\cxpl\codes;
int X, Y;
int X, Y;
[Format(4, 0);
[Format(4, 0);
Line 7,161: Line 7,161:
CrLf(0);
CrLf(0);
];
];
]</lang>
]</syntaxhighlight>


{{out}}
{{out}}
Line 7,182: Line 7,182:


=={{header|zkl}}==
=={{header|zkl}}==
<lang zkl>fcn multiplicationTable(n){
<syntaxhighlight lang=zkl>fcn multiplicationTable(n){
w,fmt := (n*n).numDigits, " %%%dd".fmt(w).fmt; // eg " %3".fmt
w,fmt := (n*n).numDigits, " %%%dd".fmt(w).fmt; // eg " %3".fmt
header:=[1..n].apply(fmt).concat(); // 1 2 3 4 ...
header:=[1..n].apply(fmt).concat(); // 1 2 3 4 ...
Line 7,191: Line 7,191:
[a..n].pump(String,'*(a),fmt).println();
[a..n].pump(String,'*(a),fmt).println();
}
}
}(12);</lang>
}(12);</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>