Created
July 14, 2010 14:46
-
-
Save d1b/475498 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
import java.math.BigInteger; | |
public class hahaha | |
{ | |
public static void main(String[] args) | |
{ | |
BigInteger a = new BigInteger("0"); | |
BigInteger b = new BigInteger("1"); | |
float number = 1000000; | |
while(number-- > 1) | |
{ | |
BigInteger temp = b; | |
b = b.add(a); | |
a = temp; | |
} | |
/* System.out.println(b.toString()); */ | |
} | |
} |
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
#!/usr/bin/env python | |
if __name__=="__main__": | |
a, b = 0, 1 | |
for i in range(1000000): | |
a, b = b, a + b | |
#print a | |
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 <iostream> | |
#include <gmpxx.h> | |
using namespace std; | |
int main() | |
{ | |
mpz_class a = 0; | |
mpz_class b = 1; | |
float number = 1000000; | |
while(number > 1) | |
{ | |
number--; | |
mpz_class temp = b; | |
b += a; | |
a = temp; | |
} | |
/* cout << endl << b <<endl; */ | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
c++
time ./a.out
real 0m45.657s
user 0m44.711s
sys 0m0.056s