/euler

Solutions to Project Euler problems

Primary LanguageFactorMIT LicenseMIT

Build Status

Project Euler Solutions

All solutions are provided in Factor, a dynamically typed, stack-oriented, concatenative language that offers a different perspective on functional programming.

Factor's bundled library includes tons of helpful "vocabularies" like math.combinatorics and math.primes, some of which would solve a problem with single word so I avoid making full use of them until I've implemented a concept at least once. For instance, the first time finding the prime factors of a number comes up, I'll write the code out myself, but if it comes up again in later problems, I'll just use math.primes.factors.

# Descripion Code
1 Sum of multiples of 3 or 5 < 1000 euler1.factor
2 Sum of even Fibonacci numbers < 4,000,000 euler2.factor
3 Largest prime factor of 600,851,475,143 euler3.factor
4 Largest palindrome product of [100..999] * [100..999] euler4.factor
5 Lowest common multiple of [1..20] euler5.factor
6 (Square of sum - sum of squares) of [1..100] euler6.factor
7 10,001st prime euler7.factor
8 Largest product of 13 consecutive digits in 1000-digit number euler8.factor
9 Pythagorean triplet where a + b + c = 1000 euler9.factor
10 Sum of primes below 2,000,000 euler10.factor
11 Greatest 4-in-a-row product in grid euler11.factor
12 First triangle number with over 500 divisors euler12.factor
13 First 10 digits of sum of 100 50-digit numbers euler13.factor
14 Longest Collatz sequence starting under 1,000,000 euler14.factor
15 Number of unique paths across a grid euler15.factor
16 Sum of the digits of 2^1000 euler16.factor
17 Count of letters used to represent [1..1000] euler17.factor
18 Max value path through 15-row triangluar grid euler18.factor
19 Count of Sundays in 20th century euler19.factor
20 Sum of the digits of 100! euler20.factor
21 Sum of amicable numbers under 10,000 euler21.factor
22 Sum of scores of first names based on characters, sorted position euler22.factor
23 Sum of positive numbers that are not sum of two abundant numbers euler23.factor
24 1,000,000th lexicographic permutation of 0,1,2,3,4,5,6,7,8,9 euler24.factor
25 Index of 1st 1000-digit Fibonacci number euler25.factor
26 Find n in [1..1000] where 1/n has longest decimal cycle euler26.factor
27 Product of coefficients of quadratic with greatest number of primes euler27.factor
28 Sum of values along the diagonals of a spiral grid euler28.factor
29 Count of distinct terms of a^b where a, b = [2..100] euler29.factor
30 Sum of numbers equal to sum of each digit to 5th power euler30.factor
31 Count of coin combinations that make £2 euler31.factor
32 Sum of products whose divisors/product use unique digits 1..9 euler32.factor
33 Product of denominators of digit-cancellable fractions euler33.factor
34 Sum of numbers equal to sum of factorials of digits euler34.factor
35 Count of circular primes under 1,000,000 euler35.factor
36 Sum of numbers that are palindromes in base 2 and 10 euler36.factor
37 Sum of primes that can be truncated and still be prime euler37.factor
38 Greatest 1-to-9 pandigital concatentated product euler38.factor
39 Number which is sum of greatest number of pythagorean triples euler39.factor
40 Product of exponentially increasing digits in irrational number euler40.factor
41 Greatest pandigital prime euler41.factor
42 Count of words with letters that add up to triangular numbers euler42.factor
43 Sum of pandigitals with substrings divisble by successive primes euler43.factor
44 Pentagonal number pair whose sum and difference are pentagonal euler44.factor
45 Triangular number that is also pentagonal and hexagonal euler45.factor
46 First number that invalidates Goldbach's other conjecture euler46.factor
47 First of 4 consecutive numbers with 4 distinct prime factors euler47.factor
48 Last 10 digits of sum(n^n), n = [1..1000] euler48.factor
49 Conistently increasing 4-digit prime sequence euler49.factor
50 Greatest prime < 1,000,000 that is sum of consecutive primes euler50.factor
51 Find smallest prime that is part of substituted-digits family of size 8 euler51.factor
52 First number where 2n, 3n, 4n, 5n and 6n all have same digits euler52.factor
53 Number of subsets size greater than 1,000,000 for sets size <= 100 euler53.factor
54 Determine winning poker hands euler54.factor
55 Count of potential Lychrel numbers under 10,000 euler55.factor
56 Greatest digit sum for a^b where a, b = [1..99] euler56.factor
57 Esitmations of sqrt(2) that have greater numerator euler57.factor
58 Ratio of # of primes/all #'s in diagonals of outward spiraling grid euler58.factor
59 Reverse XOR cypher of english text euler59.factor
67 Max value path through 100-row triangluar grid euler67.factor
69 Value in [1..1,000,000] where n/φ(n) is greatest euler69.factor
70 Value in [1..(10^7)-1] where n, φ(n) are permutations and n/φ(n) is least euler70.factor
71 Find closest, lower fraction to 3/7 with denominator <= 1,000,000 euler71.factor
72 Count of reduced fractions in (0,1) with denominator in [2..1,000,000] euler72.factor
79 Derive passcode from sample subsequences euler79.factor
85 Area of rectangular grid with number of sub-rectangles closest to 2,000,000 euler85.factor
92 Number of square digits chains that arrive at 89 starting under 10,000,000 euler92.factor
94 Sum of perimeters of almost equilateral triangles with integer areas euler94.factor
97 Last 10 digits of (28433×(2^7830457))+1 euler97.factor
100 Arranged probability euler100.factor
102 Count of triangles containing origin euler102.factor
104 First fibonacci number with first 9 and last 9 digits are pandigital euler104.factor