ischoolhead.jpg

 

INFM 603 - Information Technology and Organizational Context

Fall 2016 – Assignment H4

 

 

 

1)      Write a program to compute the factorial of a number in javascript.

The factorial of a number n, written as n!, is that number, multiplied by one less than the number, multiplied again by one less, etc. down to one.

 

      So 3! = 3 * 2 * 1 = 6 (remember that “*” in programming is the multiplication operator)

6! = 6 * 5 * 4 * 3 * 2 * 1 = 720

                       

                   Your program must take a number as input from the user, and print out the factorial of that number.    Again, the exact method of input and output isn’t important.    You should write the program so that it will keep taking input and computing factorials until told somehow to stop.   For this exercise, you should familiarize yourself with the “for”, “do”, and “while” constructs in javascript and use at least one of them.    Turn in the HTML file that includes the javascript program.

2)      Incorporate the style file mystyle.css from the previous assignment so that the output of your factorial program (which should be in the HTML “document” object) is displayed using your personal style sheet, such as using different fonts, colors, backgrounds, etc.

3)      Bonus:   Try adjusting the size of the output according to how big the factorial result it so that a larger result is shown in a larger font.    Be careful with this, though, since factorials get very big very fast.

 

 

 

 

 

 

 

 

 

 


Last Updated: August 19, 2016