I converted the pseudo-code here into C#, and have it recursively repeat 10,000 times. But I get a C# runtime error, StackOverflow Exception after 9217
StackOverflow Exception
9217
Don't use recursion. This is a good sample case of when you should not recurse, as you will cause a call stack overflow.
You can probably convert that to non-recursive easily.