User:Hajo/multTable

From Minetest Wiki
Jump to: navigation, search

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