home *** CD-ROM | disk | FTP | other *** search
- /*+==========================================================================
- File: Factorial.cool
-
- Summary: Computes the factorial of a number (the Value method should be
- the entry point). This class is present to provide a class
- to test with the Reflector sample.
-
- Classes: Factorial
-
- Functions: Value, calc
-
- ----------------------------------------------------------------------------
- This file is part of the Microsoft COM+ 2.0 SDK Samples
-
- Copyright (C) 1998-1999 Microsoft Corporation. All rights reserved.
- ==========================================================================+*/
-
- using System;
-
- class Factorial
- {
- /*****************************************************************************
- Function : Value
-
- Abstract: Computes the Factorial of the input (printing information to
- standard output.
-
- Input Parameters: i (the number to compute the factorial of)
-
- Returns: int
- ******************************************************************************/
- public int Value(int i)
- {
- Console.Write("Factorial::Value:");
- Console.WriteLine(i);
- int ret = calc(i);
- Console.Write("Factorial::Value returning:");
- Console.WriteLine(ret);
- return ret;
- }
-
- /*****************************************************************************
- Function : calc
-
- Abstract: Computes the Factorial of the input.
-
- Input Parameters: i (the number to compute the factorial of)
-
- Returns: int
- ******************************************************************************/
- public int calc(int i)
- {
- return((i <= 1) ? 1 : (i * calc(i-1)));
- }
- };
-