Set Operators: Distinct
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class MainClass {
public static void Main() {
int[] fl = { 2, 2, 3, 5, 5 };
var uniqueFactors = fl.Distinct();
Console.WriteLine("Prime factors of 300:");
foreach (var f in uniqueFactors) {
Console.WriteLine(f);
}
}
}
Related examples in the same category