Back to slide -- Keyboard shortcut: 'u'        next -- Keyboard shortcut: 'n'          linq/sieve-query-operator.cs - The Sieve query operator.Lecture 16 - slide 11 : 11
Program 1

using System;
using System.Collections.Generic;
using System.Linq;

public static class IEnumerableExtension {

  public static IEnumerable<long> Sieve(this IEnumerable<long> source){
      long first = source.First();
      yield return first;
      foreach (long i in source.Where(n => n % first != 0)
                               .Sieve()){
         yield return i;
      }
  }

}