Hi, I am doing some of the problems at Project Euler using Mono and C#. I am on the second problem, but I get a StackOverflowException error everytime. The code is as follows:
public decimal Solve() { decimal c, i = 0; decimal sum = 0; decimal cap = 4000000; for (;i <= cap;i++) { if (i <= 2) { sum += 1; } else { try { c = Fib(i); if (!Convert.ToBoolean(c%2)) { sum += c; } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } } return sum; } public decimal Fib(decimal n) { return Fib(n-1) + Fib(n-2); } The stacktrace is here: http://volatileminds.net/projects/euler/stacktrace.txt I haven't had a chance to test this on .NET, but thought I would get a second opinion as to whether it is a PEBKAC error or a bug. Any thoughts?
_______________________________________________ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list