Facebook
From chuj2, 5 Years ago, written in C#.
This paste is a reply to Re: Re: chuj from 44 - view diff
Embed
Download Paste or View Raw
Hits: 255
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace IO_lab03_zad04
  8. {
  9.     class Program
  10.     {
  11.         delegate int DelegateType(object arguments);
  12.         static DelegateType delegateName;
  13.         static int Fibonacci(object n)
  14.         {
  15.             int a = 0;
  16.             int b = 1;
  17.             int x = Convert.ToInt32(n);
  18.             // In N steps compute Fibonacci sequence iteratively.
  19.             for (int i = 0; i < x; i++)
  20.             {
  21.                 int temp = a;
  22.                 a = b;
  23.                 b = temp + b;
  24.             }
  25.             return a;
  26.         }
  27.  
  28.  
  29.         static void Main(string[] args)
  30.         {
  31.             delegateName = new DelegateType(Fibonacci);
  32.             IAsyncResult ar = delegateName.BeginInvoke(22, null, null);
  33.             Console.Write(delegateName.EndInvoke(ar));
  34.        
  35.         }
  36.     }
  37. }
  38.  
captcha