User:Hajo/multTable

From Minetest
< User:Hajo
Revision as of 10:56, 10 September 2017 by >Hajo (new)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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