Assignment 2 - Easy Functions.
You hand in this assignment by showing it to the lecturer when
it is completed. This assignment is dedicated to train to write
very short routines in form of functions. Here an example:
function factorial(x)
{ var y = 1; var z = 1;
while (z < x)
{ z = z+1; y = y*z; }
return(y); }
This function computes the factorial. One can also write it
as a recursive function which calls itself. In this case,
it is necessary to make sure that the call of the function
to itself uses smaller values than the original call.
function factorial(x)
{ if (x < 2) { return(1); }
return(x*factorial(x-1)); }
The task is now to write functions on your own. They can be
found in the text of the program.
Getting Started.
Log on your UNIX account and go into the correct directory.
cd public_html
Download this page onto your computer and place it on your webpage.
wget http://www.comp.nus.edu.sg/~gem1501/assignment02.html
chmod 755 *.html
The wget command copies a file into your page.
The chmod-command enables you to look with your browser at
the downloaded assignment.
Use an editor like
pico,
vi or vim
to look at the file. You can type the file name as well like
pico assignment02.html
so that the editor knows which file to edit and where to save
the changes.
Java Script Starts Here.
Java Script Ends Here.