[예제]
print("hello! world!")
function fact(n)
if n == 0 then
return 1
else
return n * fact(n-1)
end
end
print("enter a number:")
a = io.read("*n")
print(fact(a))
[결과]
hello! world!
enter a number:
5
120
[예제]
function norm(x,y)
return (x^2 + y^2)^0.5
end
function twice(x)
return 2*x
end
print(norm(3,4))
print(twice(4))
[결과]
5
8
print("hello! world!")
function fact(n)
if n == 0 then
return 1
else
return n * fact(n-1)
end
end
print("enter a number:")
a = io.read("*n")
print(fact(a))
[결과]
hello! world!
enter a number:
5
120
[예제]
function norm(x,y)
return (x^2 + y^2)^0.5
end
function twice(x)
return 2*x
end
print(norm(3,4))
print(twice(4))
[결과]
5
8
[LUA] Chap. 1 시작하기
Reviewed by kukanuc
on
3월 06, 2019
Rating:
댓글 없음: