Skip to content

Instantly share code, notes, and snippets.

@codejoust
Created February 28, 2012 14:24
Show Gist options
  • Save codejoust/1932830 to your computer and use it in GitHub Desktop.
Save codejoust/1932830 to your computer and use it in GitHub Desktop.
tricky recursion
// in c
#include <stdio.h>
void loopz(int num){
num += 1;
if (num < 10) {
loopz(num);
puts("Cannot Compute");
} else {
puts("Stopping");
}
}
loopz(0); // call the function
// in javascript
function loopz(num){
num += 1;
if (num < 10) {
loopz(num);
console.log("Cannot Compute");
} else {
console.log("Stopping");
}
}
loopz(0); // call the function
# in python
def loopz(num):
num += 1
if num < 10:
loopz(num)
print('Cannot Compute')
else:
print('Stopping')
loopz(0)
@codejoust
Copy link
Author

This program doesn't execute as expected, why?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment