Click here to Skip to main content
15,905,414 members
Home / Discussions / C#
   

C#

 
QuestionMessage Removed Pin
4-Jan-11 19:34
Sharath Hanakere4-Jan-11 19:34 
AnswerRe: Create a Sitemap User Control by using Recursion Pin
OriginalGriff4-Jan-11 20:36
mveOriginalGriff4-Jan-11 20:36 
GeneralRe: Create a Sitemap User Control by using Recursion Pin
Sharath Hanakere4-Jan-11 20:55
Sharath Hanakere4-Jan-11 20:55 
GeneralRe: Create a Sitemap User Control by using Recursion Pin
OriginalGriff4-Jan-11 20:57
mveOriginalGriff4-Jan-11 20:57 
GeneralMessage Removed Pin
4-Jan-11 22:12
Sharath Hanakere4-Jan-11 22:12 
GeneralRe: Create a Sitemap User Control by using Recursion Pin
OriginalGriff4-Jan-11 22:35
mveOriginalGriff4-Jan-11 22:35 
QuestionRe: Create a Sitemap User Control by using Recursion Pin
JacquesDP5-Jan-11 2:38
JacquesDP5-Jan-11 2:38 
AnswerRe: Create a Sitemap User Control by using Recursion Pin
OriginalGriff5-Jan-11 2:51
mveOriginalGriff5-Jan-11 2:51 
Consider yourself corrected! Laugh | :laugh:
private int Factorial (int n)
   {
   if (n < 0)
      {
      throw new ArgumentException("Factorial not defined for negative numbers");
      }
   if (n == 0)
      {
      return 1;  // Special case : 0! is defined to be one
      }
   return n * Factorial(n - 1);
   }
If you call it with 3:
Factorial(3)
Calls Factorial(3 - 1): Factorial(2)
Calls Factorial(2 - 1): Factorial(1)
Calls Factorial(1 - 1): Factorial(0)
Which returns 1.
You can add another special case @ either 2 or 1, but it looks clumsy for this example. Let's be honest, I wouldn't implement factorial this way in the real world anyway; it is just the classic example and easy to understand what is going on.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

GeneralRe: Create a Sitemap User Control by using Recursion Pin
JacquesDP5-Jan-11 2:57
JacquesDP5-Jan-11 2:57 
AnswerRe: Create a Sitemap User Control by using Recursion Pin
Abhinav S4-Jan-11 20:51
Abhinav S4-Jan-11 20:51 
QuestionUsing rdpsign.exe with c sharp and where to get it Pin
turbosupramk34-Jan-11 12:52
turbosupramk34-Jan-11 12:52 
AnswerRe: Using rdpsign.exe with c sharp and where to get it Pin
Dave Kreskowiak4-Jan-11 16:15
mveDave Kreskowiak4-Jan-11 16:15 
GeneralRe: Using rdpsign.exe with c sharp and where to get it [modified] Pin
turbosupramk34-Jan-11 16:41
turbosupramk34-Jan-11 16:41 
QuestionCreate a new additional function to use with Cristal Report (VS2005) Pin
martinergb4-Jan-11 7:02
martinergb4-Jan-11 7:02 
Questiondatagridview cell type Pin
csrss4-Jan-11 6:23
csrss4-Jan-11 6:23 
AnswerRe: datagridview cell type Pin
Dave Kreskowiak4-Jan-11 6:40
mveDave Kreskowiak4-Jan-11 6:40 
GeneralRe: datagridview cell type Pin
csrss4-Jan-11 7:02
csrss4-Jan-11 7:02 
AnswerRe: datagridview cell type Pin
Luc Pattyn4-Jan-11 7:01
sitebuilderLuc Pattyn4-Jan-11 7:01 
GeneralRe: datagridview cell type Pin
csrss4-Jan-11 7:04
csrss4-Jan-11 7:04 
QuestionDebug.Trace - wish it to act like ASSERT in MFC Pin
bob169724-Jan-11 6:05
bob169724-Jan-11 6:05 
AnswerRe: Debug.Trace - wish it to act like ASSERT in MFC Pin
Dave Kreskowiak4-Jan-11 6:36
mveDave Kreskowiak4-Jan-11 6:36 
GeneralRe: Debug.Trace - wish it to act like ASSERT in MFC Pin
bob169724-Jan-11 6:42
bob169724-Jan-11 6:42 
AnswerRe: Debug.Trace - wish it to act like ASSERT in MFC Pin
Rob Philpott4-Jan-11 6:46
Rob Philpott4-Jan-11 6:46 
GeneralRe: Debug.Trace - wish it to act like ASSERT in MFC Pin
bob169724-Jan-11 7:10
bob169724-Jan-11 7:10 
GeneralRe: Debug.Trace - wish it to act like ASSERT in MFC Pin
jschell4-Jan-11 8:07
jschell4-Jan-11 8:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.