DavidSCowan
Board Regular
- Joined
- Jun 7, 2009
- Messages
- 78
Hi
I am trying to learn about recursive programs but when I write a really simple one - to sum numbers up to n - I get #VALUE! error. Can someone please tell me what i am doing wrong.
Function mySum![Thumbs down (n) (n)](https://cdn.jsdelivr.net/joypixels/assets/8.0/png/unicode/64/1f44e.png)
Dim n As Integer
Dim result As Integer
If n <= 1 Then
result = 1
Else: result = n + mySum(n - 1)
End If
mySum
= result
End Function
Thank you
I am trying to learn about recursive programs but when I write a really simple one - to sum numbers up to n - I get #VALUE! error. Can someone please tell me what i am doing wrong.
Function mySum
![Thumbs down (n) (n)](https://cdn.jsdelivr.net/joypixels/assets/8.0/png/unicode/64/1f44e.png)
Dim n As Integer
Dim result As Integer
If n <= 1 Then
result = 1
Else: result = n + mySum(n - 1)
End If
mySum
![Thumbs down (n) (n)](https://cdn.jsdelivr.net/joypixels/assets/8.0/png/unicode/64/1f44e.png)
End Function
Thank you