User:Hajo/multTable: Difference between revisions

From Minetest
>Hajo
(new)
>Hajo
(new)
 

Latest revision as of 10:56, 10 September 2017

Multiplication-Table

based on http://rosettacode.org/wiki/Multiplication_tables#Lua

Lua - Online-IDEs

Program

io.write( "   |" )
for i = 11, 23 do
    io.write( string.format( "%#5d", i ) )
end
io.write( "\n", string.rep( "-", (23-11+1)*5+4 ), "\n" )
 
for i = 11, 23 do
    io.write( string.format( "%#2d |", i ) )
 
    for j = 11, 23 do
        if j < i then
            io.write( "     " )
        else
            io.write( string.format( "%#5d", i*j ) )
        end
    end
    io.write( "\n" )
end