using System;
using System.Linq;
using System.Collections.Generic;
namespace MyCompiler {
class Program {
public static void Main(string[] args)
{
StringFactor(new int[] { 2, 2, 2, 3, 3 });
StringFactor(new int[] { 2, 7 });
StringFactor(new int[] { 2, 3, 3 });
}
public static void StringFactor(int[] arr)
{
string res = string.Empty;
List<string> lis = new List<string>();
foreach(var ele in arr.Distinct())
{
lis.Add(
arr.Where(x => x == ele).Count() >1
? ele.ToString()+"^"+(arr.Where(x => x == ele).Count()).ToString()
:ele.ToString()
);
}
Console.WriteLine(string.Join(" x ",lis.ToArray()));
}
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: