Recursion Example #395
agabrielson
started this conversation in
General
Replies: 1 comment
-
Bug found... |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I'm trying to write a pretty basic factorial example that isn't working. Any thoughts on what is going wrong?
./gravity basicExample.gravity
4 fact 0
RESULT: NULL (in 0.0531 ms)
basicExample.gravity:
func fact (n) {
if (n is 0) return 1;
else if (n > 0) return n * fact(n-1);
}
func main () {
System.print("4 fact ", fact(4));
}
Thank you,
Anthony
Beta Was this translation helpful? Give feedback.
All reactions