This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://projecteuler.net/problem=9 | |
void Main() | |
{ | |
int P = 1000; | |
var t = Enumerable.Range(1,P) | |
.Select(a => possibleBC(a, P)) | |
.SelectMany(_ => _) | |
.Where(_=>_.Item2*_.Item2+_.Item3*_.Item3==_.Item1*_.Item1) | |
.First(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://projecteuler.net/problem=8 | |
var N = @" | |
73167176531330624919225119674426574742355349194934 | |
96983520312774506326239578318016984801869478851843 | |
85861560789112949495459501737958331952853208805511 | |
12540698747158523863050715693290963295227443043557 | |
66896648950445244523161731856403098711121722383113 | |
62229893423380308135336276614282806444486645238749 | |
30358907296290491560440772390713810515859307960866 | |
70172427121883998797908792274921901699720888093776 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13 | |
// What is the 10 001st prime number? | |
// https://projecteuler.net/problem=7 | |
void Main() | |
{ | |
var knownPrimes = new List<int>(new int[] { 2 }); | |
int N = 3; | |
while (knownPrimes.Count() < 10001) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. | |
// What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? | |
// https://projecteuler.net/problem=5 | |
void Main() | |
{ | |
var bop = new BagOfPrimes(); | |
Enumerable.Range(1, 20) | |
.Select(d=>dividersOf(d).GroupBy(_=>_).Aggregate(bop, (c,n) => c.add(n)).value) | |
.Dump(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. | |
// Find the largest palindrome made from the product of two 3-digit numbers. | |
// https://projecteuler.net/problem=4 | |
void Main() | |
{ | |
// xyz * XYZ = abccba | |
foreach (var p in sixDigitPalindroms()) | |
{ | |
foreach (var prm in permutationsOf(dividersOf(p)).Distinct(new Cmp())) | |
{ |
NewerOlder