Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
44 views1 page

Lib 2

The document contains definitions for 3 functions - fact calculates the factorial of a number n recursively by multiplying n by the factorial of n-1, norm calculates the norm (length) of a vector by taking the square root of the sum of the squares of x and y, and twice simply returns twice the value of its input n.

Uploaded by

funbuddha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views1 page

Lib 2

The document contains definitions for 3 functions - fact calculates the factorial of a number n recursively by multiplying n by the factorial of n-1, norm calculates the norm (length) of a vector by taking the square root of the sum of the squares of x and y, and twice simply returns twice the value of its input n.

Uploaded by

funbuddha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

function fact (n)

if n <= 0 then
return 1
else
return n * fact(n-1)
end
end

function norm (x, y)


return math.sqrt(x^2 + y^2)
end

function twice (n)


return 2.0 * n
end

You might also like