You might find something weird about this code, but i got curious about the largest yet computable value of Fibonacci's series.
static void Main(string[] args)
{
double i, a = 0, b = 1, sum = 0, numb;
Console.Write("Please enter the value: ");
numb = Double.Parse(Console.ReadLine());
if (numb == 0) // Handles the Zero case.
{
Console.WriteLine("Fib {0} = 0", numb);
Console.ReadKey();
}
else
{
for (i = 0; i < numb; i++)
{
sum = a + b;
a = b;
b = sum;
// Get the maximum computable value of Fib. (which is 1475)
if (sum.ToString().Equals("Infinity"))
{
Console.WriteLine("Maximum value of input is {0}", i);
break;
}
}
if (sum.ToString().Equals("Infinity"))
Console.ReadKey();
else
{
Console.WriteLine("Fib ({0}) = {1}", numb, sum);
Console.ReadKey();
}
}
}