Created
September 27, 2020 17:32
-
-
Save Rabios/8bb69963e147986447498d1dfd09b1fc to your computer and use it in GitHub Desktop.
Pyramid array creation example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Written by Rabia Alhaffar in August/2020 | |
local function pyramid(n) | |
local result = nil | |
if (n > 0) then | |
result = {} | |
for i = 1, n, 1 do | |
result[i] = {} | |
for j = 1, i, 1 do | |
result[i][j] = 1 | |
end | |
end | |
else | |
result = {} | |
end | |
return result | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment