using System.Collections;
static Hashtable HashTableTopDownRecurssionandDP = new Hashtable();
public static void Main()
Console.WriteLine("Hello World");
Console.WriteLine(fibannocciTCofNandSCofN(n));
Console.WriteLine(fibannocciTCofNandSCofNWithSpaceOptimized(50));
static int fibannocciTCofNandSCofN(int n)
int[] table = new int[n+1];
for(int i=2; i <=n ; ++i)
table[i] = table[i-1] + table[i-2];
static ulong fibannocciTCofNandSCofNWithSpaceOptimized(ulong n)
ulong[] table = new ulong[3];
for(ulong i=3; i <=n ; ++i)
table[i%3] = table[(i-1)%3] + table[(i-2)%3];
static int fibanocciTopDownRecurssionandDP(int n)
if(HashTableTopDownRecurssionandDP.ContainsKey(n))
return (int)HashTableTopDownRecurssionandDP[n];
HashTableTopDownRecurssionandDP[n] =fibanocciTopDownRecurssionandDP(n-1) + fibanocciTopDownRecurssionandDP(n-2);
return (int)HashTableTopDownRecurssionandDP[n];