Hi guys,
I have a bit of a formula which I am trying to put into a vb.net function and was hoping for some help in doing so. The question I have is:
Let f be the recursive function below, with f(1) = f(0) = 0. What is the value of f(1337)?
f(n) = f(n - 1) - 1 if n is divisible by 2 or 3
f(n) = f(n - 2) + 2 otherwise
Would something along the lines of this be correct?
When I run the code I get a StackOverflowException error.Code:Function F(N) If N Mod 2 = 0 Or N Mod 3 = 0 Then Return F(N - 1) - 1 Else Return F(N - 2) + 2 End If End Function
Secondly, I am wondering if there is some way of solving this formula without the use of a computer program?
Many thanks in advance!
Ozos




Reply With Quote
