Skip to content

Commit

Permalink
add more stuff, also creating nice gif images
Browse files Browse the repository at this point in the history
  • Loading branch information
hearues-zueke-github committed Sep 25, 2018
1 parent 11ce4dc commit ffa4964
Show file tree
Hide file tree
Showing 4 changed files with 304 additions and 203 deletions.
29 changes: 29 additions & 0 deletions lua_programs/fibonacci.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#! /usr/bin/lua5.3

-- defines a factorial function
function fact (n)
if n == 0 then
return 1
else
return n * fact(n-1)
end
end

function fibonacci (n)
a = 0
b = 1
i = 0
while i < n do
c = a+b
a = b
b = c
i = i+1
end

return b
end

print("enter a number:")
a = io.read("*number") -- read a number
print(fibonacci(a))
-- print(fact(a))
Loading

0 comments on commit ffa4964

Please sign in to comment.