Last active
February 5, 2016 19:47
-
-
Save noahmorrison/8e72f3b3ade61ad87b0b to your computer and use it in GitHub Desktop.
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
#include <stdio.h> | |
int main(int argc, char *argv[]) | |
{ | |
printf("Language: C\n"); | |
printf("%d\n", fib(atoi(argv[1]))); | |
return 0; | |
} | |
int fib(int n) | |
{ | |
if (n == 0) | |
return 0; | |
if (n == 1) | |
return 1; | |
return fib(n-1) + fib(n-2); | |
} |
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
import os | |
import strutils | |
proc fib(n: int): int = | |
if n == 0: | |
return 0 | |
if n == 1: | |
return 1 | |
return fib(n - 1) + fib(n - 2) | |
echo("Language: nim") | |
echo(fib(commandLineParams()[0].parseInt())) |
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
import sys | |
def fib(n): | |
if n == 0: return 0 | |
if n == 1: return 1 | |
return fib(n - 1) + fib(n - 2) | |
print('Language: Python (' + sys.executable + ')') | |
print(fib(int(sys.argv[1]))) |
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
fn fib(n: i32) -> i32 { | |
match n { | |
0 => 0, | |
1 => 1, | |
_ => fib(n - 1) + fib(n - 2) | |
} | |
} | |
fn main() { | |
println!("Language: Rust"); | |
println!("{}", fib(40)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment