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

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

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

This document contains code for two functions - fact, a recursive function that calculates the factorial of a given number n, and norm, a function that calculates the norm (or magnitude) of a vector given by its x and y components by taking the square root of the sum of their squares.

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)
40 views1 page

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

This document contains code for two functions - fact, a recursive function that calculates the factorial of a given number n, and norm, a function that calculates the norm (or magnitude) of a vector given by its x and y components by taking the square root of the sum of their squares.

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

You might also like