PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""Lua in Sololearn with input() support"""
# Fibonacci enter a range from 10 to 50
import os
def install(package):
__import__('os').system("pip -qqq install --upgrade pip")
__import__('os').system("pip install -qq --target='/usercode' " + package)
install("lupa")
import lupa
from lupa import LuaRuntime
lua = LuaRuntime(unpack_returned_tuples=True)
lua_code = '''
local n = io.read("*n")
-- Iterative Fibonacci (efficient)
local a, b = 0, 1
if n == 0 then
print ("Fibonacci(0) = 0")
else
print("Iterative approach:")
end
for i = 0, n do
print("Fibonacci (".. i .. ") = " .. a)
Enter to Rename, Shift+Enter to Preview
OUTPUT
Uruchom