Untitled

mail@pastecode.io avatar
unknown
csharp
a year ago
656 B
0
Indexable
Never
using System;
using System.Threading;

class Program {
    static void Main(string[] args) {
        Thread t1 = new Thread(() => PrintFibonacci(0, 5));
        Thread t2 = new Thread(() => PrintFibonacci(5, 10));
        t1.Start();
        t2.Start();
        t1.Join();
        t2.Join();
        Console.ReadLine();
    }

    static void PrintFibonacci(int startIndex, int endIndex) {
        int a = 0, b = 1, c;
        for (int i = 0; i < endIndex; i++) {
            if (i >= startIndex) {
                Console.WriteLine(a);
            }
            c = a + b;
            a = b;
            b = c;
        }
    }
}