Created
February 28, 2012 14:24
-
-
Save codejoust/1932830 to your computer and use it in GitHub Desktop.
tricky recursion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in python | |
def loopz(num): | |
num += 1 | |
if num < 10: | |
loopz(num) | |
print('Cannot Compute') | |
else: | |
print('Stopping') | |
loopz(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This program doesn't execute as expected, why?