using System;
using System.Linq;
using System.Numerics;
public static class Factorial
{
public static void Main(string[] args)
{
int num = 100;
Console.WriteLine(Enumerable.Range(1, num).Select(i => new BigInteger(i)).Aggregate((a, b) => a * b));
}
}
// 93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000
Tag: Linq
Reverse string with single line of C# code.
using System;
using System.Linq;
static class ReverseString
{
public static void Main()
{
string text = "!uoy htiw eb ecrof eht yaM";
Console.WriteLine(string.Join("", text.Reverse()));
}
}
Easy way to find all palindromes inside string array using C#.
using System;
using System.Linq;
static class Palindromes
{
private static void Main()
{
string[] words = { "test", "notPalindrome", "azuruza", "aha", "what?", "b" };
Console.WriteLine(string.Join(", ", words.Where(w => w.SequenceEqual(w.Reverse()))));
}
}