Skip to content

Instantly share code, notes, and snippets.

@ProblemaResolt
Created July 4, 2018 01:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ProblemaResolt/716d7a5ed466e72cd80e1edf1cc2e5b9 to your computer and use it in GitHub Desktop.
Save ProblemaResolt/716d7a5ed466e72cd80e1edf1cc2e5b9 to your computer and use it in GitHub Desktop.
fibonatch 数列 C#
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
Stopwatch watch = new Stopwatch();
watch.Start();
for (int i = 0; i < 100000; i++) {
fib(50);
}
watch.Stop();
Console.WriteLine("time" + watch.Elapsed);
Console.WriteLine(fib(50));
Console.Read();
}
static UInt64 fib(int n)
{
UInt64 fib01,fib02;
fib01 = 0;
fib02 = 1;
for (int i = 1; i < n; i++)
{
UInt64 a = fib01 + fib02;
fib01 = fib02;
fib02 = a;
}
return fib02;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment