lab_dict
Devious Dictionaries: Cleverness Through Association
 All Classes Namespaces Files Functions Variables
fac.cpp File Reference

Contains factorial-calculating functions both utilizing and not utilizing memoization. More...

Functions

int main (int argc, char *argv[])
 
unsigned long fac (unsigned long n)
 Calculates the factorial of the given number. More...
 
unsigned long memoized_fac (unsigned long n)
 Calculates the factorial of the given number. More...
 

Variables

const string USAGE
 

Detailed Description

Contains factorial-calculating functions both utilizing and not utilizing memoization.

Author
Matt Joras
Date
Winter 2013

Function Documentation

unsigned long fac ( unsigned long  n)

Calculates the factorial of the given number.

Parameters
nNumber to calculate factorial for.
Returns
n!.
unsigned long memoized_fac ( unsigned long  n)

Calculates the factorial of the given number.

This version utilizes memoization.

Parameters
nNumber to calculate factorial for.
Returns
n!.

Variable Documentation

const string USAGE
Initial value:
=
"USAGE: fac [NUM] [OPTIONS]\n"
"Calculates [NUM]! .\n"
"\n"
" -m Use memoization (defaults to not).\n"