Cookie 3

Is N a factorial?

Goal:

 Solve this problem and get a small prize.

Rules:

 No outside help (book, friend, Internet, etc).  This is just you and your brain.

Problem:

          Using only what you know from Lessons 6-7 (i.e. no use of the factorial() function!), create a MATLAB program to figure out whether a given number is a factorial or not.  If the number is a factorial, present the user feedback as shown below.  If the number is not a factorial, show the two factorials that bracket the number.  Look at the following example: 

>> isfactorial(24)
24 is a factorial: 4! = 24

>> isfactorial(25)
25 is NOT a factorial: 4! = 24
25 is NOT a factorial: 5! = 120

In order to solve this problem in the manner described above, you will need to name your MATLAB program isfactorial.m, be in that directory (or have it in your path) to run the program, and use the following for your first line of your program: 

	function isfactorial(N)

where N is the variable that holds the potential factorial number being checked. It is also acceptable to create a program without any inputs to the program and use an input() statement to query the user to enter a number.  
 

Turn-in:

          Upload to the course web site before Lesson 8 into the cookie jar (a.k.a. the "DropBox") or email it to me if the link is broken.