User:Hajo/multTable

From Minetest Wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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