Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Reflection.Emit;
- namespace ConsoleApplication1945
- {
- internal class Program
- {
- public static void Main()
- {
- Console.WriteLine(Fib(10));
- }
- public static int Fib(int number)
- {
- if (number < 0) throw new ArgumentException();
- var first = 0;
- var second = 1;
- if (number == 0) return first;
- if (number == 1) return second;
- for (var i = 2; i <= number; i++)
- {
- var temp = first + second;
- first = second;
- second = temp;
- }
- return second;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement