Created
September 23, 2013 23:35
-
-
Save aoisensi/6678457 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
using System; | |
using System.Numerics; | |
class Program | |
{ | |
private static BigInteger fib(int n) | |
{ | |
Func<BigInteger, BigInteger, int, BigInteger> fn = null; | |
fn = (x, y, i) => (i > 0 ? fn(y, x + y, i - 1) : y); | |
return fn(new BigInteger(1), new BigInteger(0), n); | |
} | |
static void Main(string[] args) | |
{ | |
string input; | |
while ((input = Console.ReadLine()) != "") | |
{ | |
int n; | |
if (!int.TryParse(input, out n)) break; | |
Console.WriteLine(fib(n)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment