Here is the example of different definition of Fibonacci series .
using System;
using System.Collections.Generic;
using System.IO;
using System.Numerics;
namespace HackerDemo
{
public class HandlingBiginteger
{
public void HandlingBigintegerMain()
{
string[] arr_int = Console.ReadLine().Split(' ');
BigInteger t0 = BigInteger.Parse(arr_int[0]);
BigInteger t1 = BigInteger.Parse(arr_int[1]);
int n = Convert.ToInt32(arr_int[2]);
BigInteger t2 = 0;
for (int i = 2; i < n; i++)
{
t2 = t0 + (t1 * t1);
t0 = t1;
t1 = t2;
}
Console.WriteLine(t2);
}
}
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Numerics;
namespace HackerDemo
{
public class HandlingBiginteger
{
public void HandlingBigintegerMain()
{
string[] arr_int = Console.ReadLine().Split(' ');
BigInteger t0 = BigInteger.Parse(arr_int[0]);
BigInteger t1 = BigInteger.Parse(arr_int[1]);
int n = Convert.ToInt32(arr_int[2]);
BigInteger t2 = 0;
for (int i = 2; i < n; i++)
{
t2 = t0 + (t1 * t1);
t0 = t1;
t1 = t2;
}
Console.WriteLine(t2);
}
}
}
No comments:
Post a Comment